I ran into the following issue when the working my current project where the client wanted some treatment to all images to fit within their layout:

http://drupal.org/node/162543

The original poster gave enough to go off of, especially the sample PHP code to create the rounded corners. However, it was going to require some changes to the imagecache module itself. To me, it makes more sense to offer a hook from IC that allows other modules create additional actions that can be added to presets as the user sees fit. Attached is a patch of imagecache.module that offers a new hook "hook_imagecache_actions". This hook has the following parameters:

$op - A string of 'list', 'form' and 'execute'. When 'list', return an array where the keys are action function names (ex. 'scale') and the values are arrays with the keys 'name' and 'description' that will be used in the help text and drop-down for adding new actions. When 'form', return an array of form elements that define the options for the given action function. When 'execute', perform the actual image manipulation.

$a2 - When $op is 'form', the action function name (ex. 'scale'). When 'execute', action settings (keys 'data', etc.).

$a3 - When $op is 'form', the already stored data for this action. When 'execute', the "tmpdestination" path.

I already rearranged scale, resize and crop to use these hooks as an example. I've prepared an additional module to implement the rounded corner action as well and will post it on the issue in the above link.

This is my first attempt at writing an implementable hook so any criticism is more than welcome. It seems like a good way to offer new features (watermark, flip, monochrome, etc.) without having to alter imagecache.

CommentFileSizeAuthor
hook_imagecache_actions.patch12.03 KBcelston

Comments

celston’s picture

Oops...didn't see this:

http://drupal.org/node/141370

jpetso’s picture

Status: Active » Closed (duplicate)

Which would make this issue a duplicate, if I'm not mistaken. As you already crosslinked all important issues, I think it shouldn't hurt to set the status of this one to "duplicate".