Would it be possible to add token support to pretty much every option? This module is already incredible and with token support everywhere it could be even easier to let content managers manipulate the results.
Thanks!

Comments

fietserwin’s picture

Ehhhm, I'm not sure that I understand your request. do you really mean that every input field on every effect form should have token support? Thus all width fields, height fields, color fields, etc?

dman’s picture

Yeah, some specific use-cases and recipes could be considered. But 'all' is a bit vague.

In my experience, token generation (in D6 anyway, hopefully less in D7 ?) was an intensely expensive procedure with many unused values being generated each time just in case a string *may* want it. Even the reverse-lookup that tries to retrieve an images context (which is where the most useful data that may eventually find its way into tokens comes from) is somewhat inefficient, so does-not/should-not be run unless it's totally necessary.
Therefore my feeling is that *if* someone wanted to add token support to fields, if that happens it should be toggled on as needed, not just thrown at everything.

Delty’s picture

OK, so not every field (yes, I was definitely a bit vague,) but I think some of the effects could benefit from allowing token input for color, and any effect where you can specify an image from the file system.
I think adding token support to just a few key bits would increase its utility that much more.

So for color that would be Color Shift and Color Overlay, and Define Canvas. For images, Overlay (watermark), Underlay, and Image Mask.

This is hands-down one of the most useful mods for Drupal and I can't thank you enough for all the time and effort you guys have put into it already. I for one greatly appreciate your efforts!

-=Delty

fietserwin’s picture

Did you try a custom action that creates a temporary image effect array and subsequently calls image_effect_apply($image, $myTmpEffect);?

Delty’s picture

No, mainly because I'm an old llama and my programming skills are in languages not used much any more (e.g 8/16-bit Asembler, Pascal, etc.) I did look around for some examples of how to do this kind of thing, but honestly I just suck at PHP.

Delty’s picture

Did you try a custom action that creates a temporary image effect array and subsequently calls image_effect_apply($image, $myTmpEffect);?

I would love to see an example of how exactly to do this.
Thanks!

Ajithlal’s picture

I think canvas action effects (overlay, underlay) can have a token support for file paths.

fietserwin’s picture

Status: Active » Closed (won't fix)

As indicated we are afraid of going through all effects and making all options accept tokens. If you need "dynamic parameters" for a certain effect, go for a custom action that calls the effect for which you need dynamic values. Example:

$data = array(
     'xpos' => 'center',
    'ypos' => 'center',
    'alpha' => '100',
    'scale' => '',
    'path' => 'module://imagecache_actions/tests/black-ribbon.gif',
);
return canvasactions_file2canvas_effect($image, $data);

Thus:
- You have to know the effect callback or you find out by inspecting image effect info.
- You can call image_toolkit_invoke() as well but that often accepts more/other parameters and not keywords like e.g. center for positions.

Test with this exported image style:

a:3:{s:4:"name";s:12:"test-1666912";s:5:"label";s:12:"test-1666912";s:7:"effects";a:2:{i:13;a:3:{s:4:"name";s:24:"imagecache_customactions";s:4:"data";a:1:{s:3:"php";s:232:"$data = array(
     'xpos' => 'center',
    'ypos' => 'center',
    'alpha' => '100',
    'scale' => '',
    'path' => 'module://imagecache_actions/tests/black-ribbon.gif',
);
return canvasactions_file2canvas_effect($image, $data);
";}s:6:"weight";s:1:"1";}i:285;a:3:{s:4:"name";s:24:"imagecache_customactions";s:4:"data";a:1:{s:3:"php";s:240:"$data = array(
     'xpos' => '0',
    'ypos' => '0',
    'alpha' => '100',
    'scale' => '25',
    'path' => 'module://imagecache_actions/docs/polaroid-template-transparent.png',
);
return canvasactions_file2canvas_effect($image, $data);
";}s:6:"weight";s:1:"2";}}}

I will update the readme with this example code.