function imagecache_actions_get_image_effect_context in ImageCache Actions 7
Returns information about the context, image style and image effect id, of the current image effect.
Note that this information is not alterable, that is, it will not have any effect on the rest of the derivative image generation process including its subsequent effects.
This information is called by effects that may need contextual information or that allow custom PHP:
- Custom action.
- Text from image alt or title.
- Text with tokens.
- Text from PHP code.
This information is fetched by traversing the backtrace, looking for known functions that have the image style or effect as argument..
Return value
array Array with keys 'image_style' and 'image_effect_id' pointing to the current image style (array) resp. image effect id (int).
2 calls to imagecache_actions_get_image_effect_context()
- imagecache_customactions_effect in customactions/
imagecache_customactions.module - Image effect callback for the custom action effect.
- image_effects_text_get_text in image_effects_text/
image_effects_text.inc - Get the text to use for this image.
File
- ./
utility.inc, line 256 - utility.inc: uitility form, conversion and rendering functions for image processing.
Code
function imagecache_actions_get_image_effect_context() {
$result = array();
$backtrace = debug_backtrace();
foreach ($backtrace as $function_call) {
if ($function_call['function'] && $function_call['function'] === 'image_effect_apply') {
$result['image_effect_id'] = isset($function_call['args'][1]['ieid']) ? $function_call['args'][1]['ieid'] : NULL;
}
else {
if ($function_call['function'] && $function_call['function'] === 'image_style_create_derivative') {
$result['image_style'] = isset($function_call['args'][0]) ? $function_call['args'][0] : NULL;
}
}
if (count($result) === 2) {
break;
}
}
$result += array(
'image_effect_id' => NULL,
'image_style' => NULL,
);
return $result;
}