This add-on adds the ability to delete attachments based on whether the attachment is attached to a post or not.
You can delete attachments based on the following options.
- Delete all attachments that are not attached to a post
- Delete all attachments that are attached to a post
- Delete all attachments based on their mime type (like image, video, audio etc)
In addition to the above options, you can also choose the following
- Whether to move the attachment to trash or permanently delete them
- Restrict attachments based on the created date
- Limit only to the first x number of attachments
Deleting attachments of posts that are getting deleted in other modules
This add-on also provides a new checkbox with the label ‘Delete associated attachments’ in all the other ‘Delete Posts’ modules which can be used to delete the attachments of all the posts that are getting deleted.
The below screenshot shows how this new checkbox in the ‘Delete Posts by Status’ module. Do note that this checkbox will be enabled only when posts are going to be permanently deleted. Attachments can’t be deleted if the post is only moved to trash.
This add-on has the following filters that can be used by developers to extend the functionality.
This filter can be used to hide the “Delete attached attachments” option. To enable the filter just add the following line to your
functions.php file or any plugin.
add_filter( 'bd_attachments_show_delete_attached', '__return_false' );
This add-on only provides the ability to delete posts based on attachment. If you want to schedule deletion of attachments automatically, then you would need the “Scheduler for Deleting Attachments” add-on.
Requires at least v5.5 or above of Bulk Delete plugin.