function image_field_delete_instance in Drupal 7
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']);
}
}