file_delete
The File Delete module adds the ability to easily delete files —both private and public— within Drupal administration.
It changes files from the "Permanent" status to the "Temporary" status. These files will be deleted by Drupal during its cron runs.
If a file is registered as being used somewhere, the Module will not allow it to be deleted.
Differences from core functionality
- Built in safeguard that won't delete a file that has usage.
- Option to delete form immediately, skipping core's file cleanup step.
- Option to force delete a file, skipping the built-in access check.
- Bulk plugins for doing mass deletions.
Other modules to consider
Media file delete - Media file delete gives content editors the option to delete the associated file when deleting a media entity.
Usage Notes
File is set to 'Temporary' but not getting deleted after a cron run
In Drupal, Temporary files generally kept for some time — default 6 hours — before being deleted.
You can configure this time in Administration » Configuration » Media » File System
Working with Drupal Media
If you added an image to the website as a Drupal Media entity, you will have to follow these steps.
- Important: Confirm that this Media is not being used in your site.
- Delete this Media entity in Administration » Content » Media
- Now you can delete the file in Administration » Content » Files
Why is this the case?
Drupal's File Usage system still needs some work. It does not correctly track all usages within Drupal. Most of the work related to this is being tracked in #2821423: Dealing with unexpected file deletion due to incorrect file usage
Specific to Drupal Media, the work is being tracked in #2835840: Track media usage and present it to the site builder (in the media library, media view, on media deletion confirmation, etc.)