function resmushit_effect in reSmush.it image style optimizer 7.2
Same name and namespace in other branches
- 7 resmushit.inc \resmushit_effect()
Parameters
\stdClass $image:
Return value
bool Execute image optimalization through reSmush.it.
1 string reference to 'resmushit_effect'
File
- ./
resmushit.inc, line 27 - Additional functions.
Code
function resmushit_effect(&$image, $data) {
// https://api.drupal.org/api/examples/image_example%21image_example.module/function/image_example_colorize_effect/7.x-1.x
// Image manipulation should be done to the $image->resource, which will be automatically saved as a new image once all effects have been applied.
// If your effect makes changes to the $image->resource that relate to any information stored in the $image->info array (width, height, etc.) you should update that information as well.
// Note that the size of the file here is may be influenced by any preceding image styles (e.g., resizing).
$currentstyle = FALSE;
$item = menu_get_item();
// We find the currently generated image style in $item['map'], there is one single array, and that contains the style name.
$item_map = resmushit_recursiveFind($item, 'map');
foreach ($item_map as $val) {
if (is_array($val)) {
if (!empty($val['name'])) {
$currentstyle = $val['name'];
break;
}
}
}
if ($currentstyle === FALSE) {
watchdog('reSmush.it', 'Could not determine the currently generated image style name. Known to happen if an image is created but not immediately displayed (e.g. added by cron).', NULL, WATCHDOG_NOTICE);
return;
}
$currentstylepath = image_style_path($currentstyle, $image->source);
$GLOBALS['resmushit_todo'] = $currentstylepath;
}