You are here

function image_field_storage_config_delete in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/image/image.module \image_field_storage_config_delete()
  2. 9 core/modules/image/image.module \image_field_storage_config_delete()

Implements hook_ENTITY_TYPE_delete() for 'field_storage_config'.

File

core/modules/image/image.module, line 452
Exposes global functionality for creating image styles.

Code

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::service('entity.repository')
    ->loadEntityByUuid('file', $uuid))) {
    \Drupal::service('file.usage')
      ->delete($file, 'image', 'default_image', $field
      ->uuid());
  }
}