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.
I have an imagecache preset using text Actions. If I use the output return '123 my street';
then the text is overlayed on the image properly.
I'm calling the preset via a PHP script using:
$oputpath = 'newsletter/weekly/'.$pickreason."_".$thismls.'.jpg';
print theme('imagecache', 'weeklyfeaturethumb', $oputpath, $altinfo, $title, $attributes);
I want to be able to send a variable to the preset to overlay text (which changes depending on the image). I have tried prefixing the image path (as above example) but it takes the placeholder image filename not what I am sending. In an ideal world I would want something like:
global $mysentvariable;
return $mysentvariable;
To grab a global variable and output. I think this is an easy bit of code to achieve but I'm overthinking it. Any help appreciated!
Comments
Comment #1
dman CreditAttribution: dman commented#642048: No, you can't pass 'arguments' to imagecache_actions. Here's why
The process that builds the theme HTML and the process that builds the image JPEG are different unique HTTP requests. Nothing in $_GLOBALS or anything will be communicated between them. (in theory maybe $_SESSION, but that would be madness)
If you are wanting to build the image differently depending on the code-based circumstances within which you called it, you don't want image(cache) behavior, you want a different image generation pipeline that builds and returns your image on demand instead.
Comment #2
fietserwinBut if you are sure that an image is always only used in 1 context (e.g. a single node) you could lookup that node by searching the image field table for the original image and from there on traverse to the node and the info you want. D7 text image efffect has this code (but for D7).
Last aternative: insgtead of prepending thepath, add a query string to the URL. As the rest of the URL is needed by imageacache to create the correct derivative you cannot play with that, you can add a query string though. But remember that only the first time when the image derivative is requested Drupal is invoked and this info is passed.
Comment #3
fietserwinD6 EOL.