$triggering_element =
$form_state->
getTriggeringElement();
$delta =
array_slice($triggering_element['#array_parents'
], -2, 1
)[0
];
/** @var \Drupal\media\MediaInterface $removed_media */
$removed_media =
$form_state->
get(['media',
$delta]);
$file =
$removed_media->
get($this->
getSourceFieldName($removed_media->bundle->entity
))->entity;
if ($file instanceof FileInterface &&
empty($this->fileUsage->
listUsage($file))) { $file->
delete();
} parent::
removeButtonSubmit($form,
$form_state);
}}