function image_field_delete_instance
Implements hook_field_delete_instance().
File
-
modules/
image/ image.module, line 478
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']);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.