function _manualcrop_update_style_name_in_image_effect in Manual Crop 7
Update or remove a style name in all Manual Crop reuse image effects.
Parameters
$style_name: Current image style name.
$new_style_name: New image style name if renamed, a NULL value will remove the effect from the style.
2 calls to _manualcrop_update_style_name_in_image_effect()
- manualcrop_image_style_delete in ./
manualcrop.module - Implements hook_image_style_delete().
- manualcrop_update_style_name in ./
manualcrop.admin.inc - Style form submit handler; Update the style name in the effect data and in the widgets.
File
- ./
manualcrop.helpers.inc, line 988 - Helper functions for the Manual Crop module.
Code
function _manualcrop_update_style_name_in_image_effect($style_name, $new_style_name = NULL) {
foreach (image_styles() as $style) {
if (!empty($style['effects'])) {
// Check if the first effect is a Manual Crop effect.
$effect = reset($style['effects']);
// Check if this is a Manual Crop reuse effect.
if (_manualcrop_is_own_effect($effect)) {
$data = $effect['data'];
$key = isset($data['reuse_crop_style']) ? 'reuse_crop_style' : 'fallback_style';
// Only update if needed.
if (isset($data[$key]) && $data[$key] == $style_name) {
if (is_null($new_style_name) && $effect['name'] == 'manualcrop_reuse') {
// The reuse effect requires an image style.
image_effect_delete($effect);
}
else {
$effect['data'][$key] = $new_style_name;
image_effect_save($effect);
}
}
}
}
}
}