1 image.module | image_field_update_field($field, $prior_field, $has_data) |
Implements hook_field_update_field().
File
- core/
modules/ image/ image.module, line 405 - Exposes global functionality for creating image styles.
Code
function image_field_update_field($field, $prior_field, $has_data) {
if ($field['type'] != 'image') {
return;
}
$uri_new = $field['settings']['default_image'];
$uri_old = $prior_field['settings']['default_image'];
// Delete the old file if any.
if ($uri_old && $uri_new != $uri_old) {
file_unmanaged_delete($uri_old);
}
// If the upload destination changed, then move the file.
if ($uri_new && (file_uri_scheme($uri_new) != $field['settings']['uri_scheme'])) {
$directory = $field['settings']['uri_scheme'] . '://default_images/';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
file_unmanaged_move($uri_new, $directory . basename($uri_new));
}
}