orphans_media
Orphans Media Delete is a lightweight and efficient module designed to help administrators identify and delete unused media entities in their Drupal site. Inspired by the Audit Files module, this tool provides a flexible administrative interface to manage orphaned media and maintain a clean, optimized media library.
Features
- List Unused Media: Scan your site to identify media entities that are not referenced in any content.
- Filter by Media Bundle: Limit the search to specific media bundles, giving you control over which types of media to target.
- Delete Unused Media: Remove orphaned media directly from the admin interface to free up storage and improve site performance.
- Batch Operations: Handles large media libraries efficiently using Drupal's batch processing system.
- Safe Workflow: Prevent accidental deletion by displaying a detailed preview of unused media before removal.
-
Customizable Workflow with Events:
- Pre Delete Event: Triggered before a media entity is deleted, for additional processing or logging
- Post Delete Event: Triggered after a media entity is deleted, providing a clone object of deleted media entity, enabling cleanup tasks or notifications.
Use Cases
- Maintaining a well-organized media library.
- Reducing storage usage by removing obsolete media entities.
- Simplifying content management for administrators.
- Adding custom logic to deletion workflows using provided events.
Requirements
- Compatible with Drupal 10 and above.
- Media module must be enabled and in use on the site.
How It Works
The module analyzes all media entities in your site and cross-checks their usage across content entities. Administrators can filter results by media bundle to refine their search. Orphaned media are displayed in a report accessible from the administrative interface. After review, unused media can be deleted in bulk.
For developers, the module emits pre delete and post delete events, allowing for custom workflows or additional processing during the deletion process.