diff --git a/src/Form/ConfirmDeleteMediaAndFile.php b/src/Form/ConfirmDeleteMediaAndFile.php index 64c1bff3c..154d45cc0 100644 --- a/src/Form/ConfirmDeleteMediaAndFile.php +++ b/src/Form/ConfirmDeleteMediaAndFile.php @@ -134,6 +134,15 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $file = File::load($target_id); if ($file) { if (!$file->access('delete', $this->currentUser)) { + // May not be allowed access because it is a default thumbnail for media type. + if ($field->getName() == 'thumbnail') { + $default_thumbnail_filename = $entity->getSource()->getPluginDefinition()['default_thumbnail_filename']; + $default_thumbnail_uri = \Drupal::config('media.settings') + ->get('icon_base_uri') . '/' . $default_thumbnail_filename; + if ($default_thumbnail_uri == $file->getFileUri()) { + continue; + } + } $inaccessible_entities[] = $file; continue; }