On this page
function image_field_delete_instance
image_field_delete_instance($instance)
Implements hook_field_delete_instance().
File
- modules/image/image.module, line 478
- Exposes global functionality for creating image styles.
Code
function image_field_delete_instance($instance) {
// Only act on image fields.
$field = field_read_field($instance['field_name']);
if ($field['type'] != 'image') {
return;
}
// The value of a managed_file element can be an array if the #extended
// property is set to TRUE.
$fid = $instance['settings']['default_image'];
if (is_array($fid)) {
$fid = $fid['fid'];
}
// Remove the default image when the instance is deleted.
if ($fid && ($file = file_load($fid))) {
file_usage_delete($file, 'image', 'default_image', $instance['id']);
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!image!image.module/function/image_field_delete_instance/7.x