Administrators usually create presets with one or more actions, but it is possible to create a preset with no actions. Where no actions are specified for a preset, an image is served up without transformation. Currently imagecache loads and saves the image using imageapi, even where no actions are specified. This destroys animated .gifs.

Here is my use case. I'm using the ad_image module to serve up ads. The ad_image module does not check for last modified headers so images are served up on every request. I could duplicate the imagecache checking for file modification times into the ad_image module. But, I would prefer to take advantage of the existing code in imagecache by creating a 'banner' preset with no actions. However, the imagecache module breaks my animated .gif files (it removes all frames after the first one).

The attached patch simply performs a file_copy where there are no actions specified.

It's worth noting that a preset gives users to access any image file in the files folder, regardless of the view permission set on the module used to upload the image. For example, using the CCK imagefield module, if 'view imagefield uploads' is FALSE for anonymous users, but 'view imagecache [preset]' is TRUE for anonymous users, anonymous users may view the uploaded file (but only via the imagecache preset path). This is helpful in my use case where I want to use a 'banner' preset to serve ads to anonymous users, while denying anonymous users access to all other uploaded files. Perhaps others will be surprised by this behaviour!

Comments

Version:5.x-2.x-dev» 6.x-2.x-dev
Status:Needs review» Needs work

sorry, this needs to be committed to the 6.x version and then backported to 5.x-2.x.

that said i think it's a great idea and i'd be interested in seeing it get in.

Status:Needs work» Needs review
StatusFileSize
new3.08 KB

I've rerolled and attached the patch for 6.x. The patch amounts to the addition of the following lines ahead of the normal imageapi_image_open/close action processing in imagecache_build_derivative:

// Simply copy the file if there are no actions.
if (empty($actions)) {
  return file_copy($src, $dst, FILE_EXISTS_REPLACE);
}
else { ...

that changed a lot more than it needed to. committing a slimmed down version to HEAD.

Status:Needs review» Fixed
StatusFileSize
new682 bytes

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.