Title: DX Delete Attached Media
Author: Mario Peshev
Published: <strong>11 Abril, 2012</strong>
Last modified: 25 Outubro, 2026

---

Procurar plugins

![](https://ps.w.org/dx-delete-attached-media/assets/banner-772x250.png?rev=1729317)

![](https://ps.w.org/dx-delete-attached-media/assets/icon-256x256.png?rev=1729317)

# DX Delete Attached Media

 Por [Mario Peshev](https://profiles.wordpress.org/nofearinc/)

[Descarregar](https://downloads.wordpress.org/plugin/dx-delete-attached-media.2.1.0.zip)

 * [Detalhes](https://pt.wordpress.org/plugins/dx-delete-attached-media/#description)
 * [Avaliações](https://pt.wordpress.org/plugins/dx-delete-attached-media/#reviews)
 *  [Instalação](https://pt.wordpress.org/plugins/dx-delete-attached-media/#installation)
 * [Desenvolvimento](https://pt.wordpress.org/plugins/dx-delete-attached-media/#developers)

 [Suporte](https://wordpress.org/support/plugin/dx-delete-attached-media/)

## Descrição

DX Delete Attached Media deletes all of the attached media files to your posts once
they get deleted from the system. The standard core behavior deletes posts alone
without taking care of related images. Now you can maintain your install and get
rid of all solo attachments getting into your posts via the Media button and used
nowhere else.

_The plugin works with WooCommerce and Easy Digital Downloads._

## Ecrãs

[⌊Insert newly uploaded media to your post.⌉⌊Insert newly uploaded media to your
post.⌉[

Insert newly uploaded media to your post.

[⌊Publish and then Delete your post.⌉⌊Publish and then Delete your post.⌉[

Publish and then Delete your post.

[⌊You'll have to Delete your post Permanently.⌉⌊You'll have to Delete your post 
Permanently.⌉[

You’ll have to Delete your post Permanently.

[⌊The Attached Media is deleted.⌉⌊The Attached Media is deleted.⌉[

The Attached Media is deleted.

## Instalação

 1. Upload ‘dx-delete-attached-media’ to the ‘/wp-content/plugins/’ directory or find
    via the Plugins admin section
 2. Activate the plugin through the ‘Plugins’ menu in WordPress
 3. That’s all. It would use out of the box, no settings needed. If you want to disable
    the functionality, disable the plugin from the Plugins section.

## Perguntas frequentes

### Does it work for custom post types?

Yes, as long as you attach images via the Media button, they are going to be deleted
once the post/post type entry is deleted.

### Does it work for all of the deleted posts?

It works for all of your deleted posts, as long as you delete them from the system.
Keep in mind that the soft delete sends your post to Trash first, and deleting the
media would happen once your Trash is being emptied.

### Which media is kept?

Files that are still used elsewhere are kept, and attached to a post that uses them.
A file counts as used when it is the featured image of another post, when the file
or any of its sizes appears in another post’s content or excerpt (matched by its
path in the uploads folder, so links from before a move to https or a new domain
count too), or when it is listed in a classic [gallery] shortcode, an Easy Image
Gallery gallery or a WooCommerce product gallery.

Every post type counts, including synced patterns, template parts and product variations,
and every status except Trash. Uses that only store the file’s ID somewhere else,
such as custom fields or page builder data, aren’t detected: add them with the filter
below.

### Can I protect media used by another plugin, such as ACF image fields?

Yes. Add the IDs of the posts that use the file with the `dx_dam_attachment_used_in`
filter, which receives the list of post IDs and the attachment ID: `add_filter( '
dx_dam_attachment_used_in', 'my_media_uses', 10, 2 );`

### Can I keep the media of some posts?

Yes. Return false from the `dx_dam_delete_post_attachments` filter, which receives`
true` and the ID of the post being deleted, and that post’s media stays in the library.

## Avaliações

![](https://secure.gravatar.com/avatar/8b3f5f7ccc4964a1241466c6a0d8058fe20450ede40d09410c9d8695a47e4521?
s=60&d=retro&r=g)

### 󠀁[Does what it says.](https://wordpress.org/support/topic/does-what-it-says-1144/)󠁿

 [pixcil](https://profiles.wordpress.org/pixcil/) 19 Maio, 2023

Where I had a custom code implementation to do what this plugin does – that caused
the site to completely destroy itself – this plugin does not. It does what it says
without any issues. And its free! Big thank you to the developers. ♥

![](https://secure.gravatar.com/avatar/e7b032145f76326f6692bddccdb000ec2d7a8b10e3b3128e8f6367ea3c4c5ec7?
s=60&d=retro&r=g)

### 󠀁[Plugin deleted media used elsewhere on the site](https://wordpress.org/support/topic/plugin-deleted-media-used-elsewhere-on-the-site/)󠁿

 [nicole2292](https://profiles.wordpress.org/nicole2292/) 27 Setembro, 2022

Unfortunately this plugin deleted media which was used elsewhere on the site. It
deleted media which was used in other posts by the ACF Image Fields and ACF Gallery
plugin. It should not delete media which is used elsewhere on the site.

![](https://secure.gravatar.com/avatar/dcaccaa48b3e8ad84d98773a6348e8256993e02ef38c6ea0305d23855a497de0?
s=60&d=retro&r=g)

### 󠀁[Perfect!](https://wordpress.org/support/topic/perfect-9346/)󠁿

 [MaxByer](https://profiles.wordpress.org/maxbyer/) 24 Junho, 2022

It does what it says, simple and easy.

![](https://secure.gravatar.com/avatar/f221c3307bacffcf4733a1820f18d50f0a642db4772112f118e5325b7d4d4dfb?
s=60&d=retro&r=g)

### 󠀁[Lifesaver!](https://wordpress.org/support/topic/lifesaver-207/)󠁿

 [jreitter](https://profiles.wordpress.org/jreitter/) 16 Novembro, 2021

I run a classifieds site with thousands of posts and images uploaded by the users.
This plugin is a total lifesaver!

![](https://secure.gravatar.com/avatar/9335de3226b6ed8babb19a8a48073bac9181c2082d80bb2b9ea745991bec25af?
s=60&d=retro&r=g)

### 󠀁[The only one that works](https://wordpress.org/support/topic/the-only-one-that-works-8/)󠁿

 [UomoMacchina](https://profiles.wordpress.org/uomomacchina/) 26 Maio, 2020

The plugin works well, but not delete the ".webp" file type. Hope the author fix
it in next update, but for me is a 5* plugin. Just install, activate and it does
the job.

![](https://secure.gravatar.com/avatar/cf3ced212409e4a92a65396ae85c49bf6fbae8ca00a86e6ea49a0976bc1e8621?
s=60&d=retro&r=g)

### 󠀁[Fabulous Plugin](https://wordpress.org/support/topic/fabulous-plugin-55/)󠁿

 [Livingstone](https://profiles.wordpress.org/livingstone/) 27 Fevereiro, 2020 1
resposta

Its a perfect plugin. No setup and/or configurations required. Serves its purpose
better. 5*. Works so well with Classifieds website, woocommerce and the like. Perfect

 [ Ler todas as 28 avaliações ](https://wordpress.org/support/plugin/dx-delete-attached-media/reviews/)

## Contribuidores e programadores

“DX Delete Attached Media” é software de código aberto. As seguintes pessoas contribuíram
para este plugin:

Contribuidores

 *   [ Mario Peshev ](https://profiles.wordpress.org/nofearinc/)
 *   [ DevriX ](https://profiles.wordpress.org/devrix/)

[Traduza o “DX Delete Attached Media” para o seu idioma.](https://translate.wordpress.org/projects/wp-plugins/dx-delete-attached-media)

### Interessado no desenvolvimento?

[Consulte o código](https://plugins.trac.wordpress.org/browser/dx-delete-attached-media/),
consulte o [repositório SVN](https://plugins.svn.wordpress.org/dx-delete-attached-media/),
ou subscreva o [registo de alterações](https://plugins.trac.wordpress.org/log/dx-delete-attached-media/)
por [RSS](https://plugins.trac.wordpress.org/log/dx-delete-attached-media/?limit=100&mode=stop_on_copy&format=rss).

## Registo de alterações

#### 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

## Metadados

 *  Versão **2.1.0**
 *  Última actualização **Há 3 semanas**
 *  Instalações activas **3.000+**
 *  Versão do WordPress ** 4.5 ou superior **
 *  Testado até **7.1.4**
 *  Versão do PHP ** 7.4 ou superior **
 *  Idioma
 * [English (US)](https://wordpress.org/plugins/dx-delete-attached-media/)
 * Etiquetas
 * [attachment](https://pt.wordpress.org/plugins/tags/attachment/)[media](https://pt.wordpress.org/plugins/tags/media/)
   [post](https://pt.wordpress.org/plugins/tags/post/)
 *  [Visualização avançada](https://pt.wordpress.org/plugins/dx-delete-attached-media/advanced/)

## Classificações

 4.9 out of 5 stars.

 *  [  27 5-star reviews     ](https://wordpress.org/support/plugin/dx-delete-attached-media/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/dx-delete-attached-media/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/dx-delete-attached-media/reviews/?filter=3)
 *  [  1 2-star review     ](https://wordpress.org/support/plugin/dx-delete-attached-media/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/dx-delete-attached-media/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/dx-delete-attached-media/reviews/#new-post)

[Ver todas as revisões](https://wordpress.org/support/plugin/dx-delete-attached-media/reviews/)

## Contribuidores

 *   [ Mario Peshev ](https://profiles.wordpress.org/nofearinc/)
 *   [ DevriX ](https://profiles.wordpress.org/devrix/)

## Suporte

Tem algo a dizer? Precisa de ajuda?

 [Ver fórum de suporte](https://wordpress.org/support/plugin/dx-delete-attached-media/)