Skip to main content
Agency Program Hosting from 10% off. A dedicated account manager. Priority support. Built for growing agencies. Hosting from 10% off, a dedicated account manager and priority support for growing agencies. Speak to the team Join free
DX Delete Attached Media icon

DX Delete Attached Media

v2.1.0
by Mario Peshev · 4.9 (28 reviews)

Automatically deletes attached media from posts and custom post types added via the Media button.

3K+ active installs Updated Oct 25, 2026 Tested to 7.1.5 Requires PHP 7.4
Try Demo Download
Pre-installed Ready in ~10s No card
DX Delete Attached Media

About DX Delete Attached Media

DX Delete Attached Media is a plugin that deletes all attached media files to your posts when they are deleted from the system. This helps maintain your install and get rid of unused attachments. The plugin is compatible with WooCommerce and Easy Digital Downloads.

Screenshots

DX Delete Attached Media screenshot
DX Delete Attached Media screenshot
DX Delete Attached Media screenshot
DX Delete Attached Media screenshot

Changelog

2.1.0

  • New: media that is still used elsewhere is no longer deleted. Besides featured images and files in post content, the plugin now checks excerpts, classic [gallery] shortcodes, Easy Image Gallery galleries, WooCommerce product galleries, posts of every status except Trash, and every post type, including synced patterns, template parts, product variations and post types of deactivated plugins. Files are matched by their path in the uploads folder, so links from before a move to https or a new domain count. Developers can add more with the dx_dam_attachment_used_in filter.
  • New: the dx_dam_delete_post_attachments filter keeps the media of a post when it returns false. The delete callback is now named dx_dam_delete_attachments; code that removed the old delete_attachments callback should use this filter.
  • New: the Trash screen shows how many media files are attached to each post.
  • Fixed: opening the plugin’s media list could detach media from posts whose post type wasn’t registered at that moment (for example products while WooCommerce was deactivated), so that media was never deleted with its post. The list now only displays.
  • Improved: the settings page uses the standard WordPress layout, and confirms changes on the page instead of pop-up alerts.
  • Fixed: a settings change could be lost when saving took longer than a second (the page reloaded too early).
  • Fixed: deleting a post without the trash (WP-CLI –force, the REST API, EMPTY_TRASH_DAYS set to 0, or another plugin deleting posts) left its media behind, orphaned. That media is now deleted too, unless it is used elsewhere.
  • Fixed: the media list page stopped with a fatal error on PHP 8 when a media item had no file.
  • Security: escaped admin output and validated the settings request.
  • Prefixed the plugin’s global functions and AJAX action to avoid conflicts with other plugins.
  • Scripts and styles now load only on the plugin’s own screens.
  • Tested with WordPress 7.1, PHP 7.4 to 8.5.

2.0.6

  • Fixed vulnerability report

2.0.5.1

  • Fix plugin conflict between DX DAM and other plugins

2.0.5

  • Fixed plugin conflict with Post SMTP

2.0.4.1

  • Revert to version 2.0.3

2.0.4

  • Fixed plugin conflict with Post SMTP

2.0.3

  • Fixed security issue
  • Update tested-up version
  • Update required PHP version

2.0.2

  • Added default icon for other formats

2.0.1

  • Added default options for the plugin filters settings
  • Fixed the issue with the subfolder instalations

2.0

  • Has been added separate menu for the plugin
  • The plugin icon has been added
  • On the main plugin page has been added a table with the following columns displaying: the media file, the parent post if is used, the other posts that contains it if is used
  • On the main plugin page, a checkbox has been added for enabling/disabling the plugin’s functionality, called ‘Enable feature’.
  • Added filter: by date (Newest/Oldest)
  • Added filter: by Parent post (Used media/Unused media)
  • A Help page has been added with instructions and screenshots describing the functionality of the plugin.

1.0.1

  • Update the plugin version and Tested up to tag

1.0

  • Extended support for WooCommerce and Easy Digital Downloads.

0.5

  • Description update and version bump

0.4

  • First release

Try other plugins

Yoast SEO icon

Yoast SEO

4.8 · 10M+ installs

Improve your WordPress SEO: Write better content and have a fully optimized WordPress site using the Yoast SEO…

LiteSpeed Cache icon

LiteSpeed Cache

4.8 · 7M+ installs

All-in-one unbeatable acceleration & PageSpeed improvement: caching, image/CSS/JS optimization...

WooCommerce icon

WooCommerce

4.5 · 7M+ installs

Everything you need to launch an online store in days and keep it growing for years. From your…