Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
fietserwinEhhhm, 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?
Comment #2
dman CreditAttribution: dman commentedYeah, 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.
Comment #3
Delty CreditAttribution: Delty commentedOK, 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
Comment #4
fietserwinDid you try a custom action that creates a temporary image effect array and subsequently calls image_effect_apply($image, $myTmpEffect);?
Comment #5
Delty CreditAttribution: Delty commentedNo, 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.
Comment #6
Delty CreditAttribution: Delty commentedI would love to see an example of how exactly to do this.
Thanks!
Comment #7
Ajithlal CreditAttribution: Ajithlal commentedI think canvas action effects (overlay, underlay) can have a token support for file paths.
Comment #8
fietserwinAs 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:
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:
I will update the readme with this example code.