MCOD Delete Media by Content
MCOD Delete Media by Content
Description
MCOD Delete Media by Content allows you to bulk delete WordPress media files attached to a specific post type. Whether you need to clean up orphaned images from deleted WooCommerce products, remove PDFs tied to a custom post type, or purge an unused media library section after a content migration, this plugin handles the process in batches.
Use it to clean your WordPress media library without touching media that is actively used elsewhere on your site based on your exclusions.
Free Up Server Inodes:
Hosting servers have a limit on the number of files (inodes) they can store, regardless of disk space. Each WordPress attachment generates multiple thumbnail files, which rapidly consumes inodes. When the inode limit is reached, no new files can be created on the server. This plugin permanently deletes media files and all their generated thumbnails from the filesystem in batches, helping to reduce your inode count and restore your server’s ability to handle new uploads.
Dual Detection Strategy:
This plugin uses a dual detection strategy to find media linked to your chosen post type by checking multiple fields:
1. Direct Parent: Attachments whose post_parent points to a post of the selected type.
2. Meta References: Attachment IDs stored in postmeta — including WooCommerce product galleries (_product_image_gallery), ACF Image & Gallery fields, featured images saved as meta, and any other custom field referencing an attachment ID.
This helps identify attachments properly without inadvertently affecting active media from other areas.
Smart Cross-Type Exclusions — Protect Shared Media:
Before deleting, the plugin cross-checks each attachment against other post types you select. If a product image is also used as a featured image on a Page or referenced in a Post, it will be automatically skipped — preventing broken images across your site.
Key Features:
- Bulk Delete by Post Type: Target Products, Pages, Posts, or any registered custom post type.
- Media Type Filter: Scope deletion to Images only, PDFs, Videos, Audio, or all attachments.
- Cross-Type Exclusions: Protect attachments shared with other post types from accidental deletion.
- Preview Mode: Count and preview a sample of media to be deleted (with direct edit links) before running.
- Safe Batch Processing: Processes in configurable batches of 1–100 items to avoid PHP/server timeouts on large media libraries.
- Real-Time Progress Log: Live status updates so you always know what is happening.
- WooCommerce & ACF Compatible: Detects images in product galleries, ACF image/gallery fields, and other postmeta.
- Fully Translatable: Internationalization-ready with a
.potfile included.
⚠️ This plugin permanently deletes media files from the database and the server filesystem. Always create a full backup before running any deletion.
Installation
- Upload the
mcod-bulk-delete-media-by-contentfolder to/wp-content/plugins/. - Activate the plugin via the ‘Plugins’ menu in WordPress.
- Go to Settings Delete Media by Content.
- Select the Post Type (source) and Media Type.
- (Optional) Select Exclusions (hold Ctrl/Cmd) to protect media shared with other content types.
- Click Count Media to see a preview of items to be deleted.
- Click Start Deletion to begin the cleanup process.
Faq
No. Media files are permanently deleted from the database and the server filesystem. Always back up your site before using this plugin.
The plugin finds attachments in two ways:
1. Direct: The attachment’s post_parent is a post of the selected type.
2. Reference: The attachment ID is found in the postmeta of the selected post type (e.g., WooCommerce product galleries, ACF fields).
Yes! Use the “Exclude if also in” field. Select the post types (e.g., Pages, Posts) you want to cross-check. If an image is found in your source but also referenced in an excluded type, it will NOT be deleted.
Yes. Click the Stop button to halt the process after the current batch finishes.
The default of 20 is safe for most servers. If your server is powerful, you can increase it up to 100. If you experience timeouts, lower it.