function image_image_style_save
Implements hook_image_style_save().
1 call to image_image_style_save()
- image_image_style_delete in modules/
image/ image.module - Implements hook_image_style_delete().
File
-
modules/
image/ image.module, line 388
Code
function image_image_style_save($style) {
if (isset($style['old_name']) && $style['old_name'] != $style['name']) {
$instances = field_read_instances();
// Loop through all fields searching for image fields.
foreach ($instances as $instance) {
if ($instance['widget']['module'] == 'image') {
$instance_changed = FALSE;
foreach ($instance['display'] as $view_mode => $display) {
// Check if the formatter involves an image style.
if ($display['type'] == 'image' && $display['settings']['image_style'] == $style['old_name']) {
// Update display information for any instance using the image
// style that was just deleted.
$instance['display'][$view_mode]['settings']['image_style'] = $style['name'];
$instance_changed = TRUE;
}
}
if ($instance['widget']['settings']['preview_image_style'] == $style['old_name']) {
$instance['widget']['settings']['preview_image_style'] = $style['name'];
$instance_changed = TRUE;
}
if ($instance_changed) {
field_update_instance($instance);
}
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.