image_field_storage_config_delete(FieldStorageConfigInterface $field)
Implements hook_ENTITY_TYPE_delete() for 'field_storage_config'.
function image_field_storage_config_delete(FieldStorageConfigInterface $field) {
if ($field->getType() != 'image') {
// Only act on image fields.
return;
}
// The value of a managed_file element can be an array if #extended == TRUE.
$uuid = $field->getSetting('default_image')['uuid'];
if ($uuid && ($file = \Drupal::entityManager()->loadEntityByUuid('file', $uuid))) {
\Drupal::service('file.usage')->delete($file, 'image', 'default_image', $field->uuid());
}
}
© 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/core!modules!image!image.module/function/image_field_storage_config_delete/8.1.x