Skip to main content

Introducing the Media File Delete module

The media and media library modules have improved Drupal's file handling capabilities considerably, but clients commonly request the ability to remove files from disk when removing the associated media entity. This is where the Media file delete module can help

by lee.rowlands /

Configuring the module

The module has no configuration, so it should be as simple as enabling it and you're off.

By default it takes over the Media entity delete form and adds an additional checkbox allowing the editor to also removed the associated file if:

  • the media-type has an associated file or image field
  • there are no associated file usage records for the file
  • the user has permission to delete the file
Screenshot showing the option to also delete the file

A word about access

By default, Drupal core's access handler for files allows editors to only delete files which they own, which can be prohibitive in an environment where several editors create and edit media.

To alleviate this, the module also comes with a 'Delete any file' permission, which can be granted to allow trusted users to delete files they don't own.

Summary

All in all, its a pretty simple module - but its a common requirement for our clients, and as a result at least two of them are already running it in production.

Take it for a spin and let us know your thoughts either here or via the issue queue.

Tagged

Media