Skip to main content
Agency Program Get 2× more leads and save 50% on hosting. Built for agencies ready to grow. Book a call
Autoremove Attachments icon

Autoremove Attachments

v1.3.1
by Polygon Themes · 5.0 (15 reviews)

Remove child attachments when parent post, page or custom post type is deleted.

3K+ active installs Updated Aug 12, 2023 Tested to 6.3.5 Requires PHP 7.4
Try Demo Download
Pre-installed Ready in ~10s No card
Autoremove Attachments

About Autoremove Attachments

Autoremove Attachments is a plugin that automatically deletes media files from your WordPress website when the content they were attached to is deleted. It helps keep your Media Library clean by removing unused files and preventing broken links. It is compatible with popular plugins like WooCommerce and Easy Digital Downloads, and it is recommended to use it alongside a database optimization plugin like WP-Sweep.

Changelog

Version 1.3.1

  • Minor improvements to admin notices

Version 1.3.0

  • Minor code refactoring
  • Language files updated

Version 1.2.1

  • Fixed a bug that blocked changes to image sizes under Settings > Media

Version 1.2.0

  • Minor code refactoring
  • Extended support for WooCommerce and Easy Digital Downloads.
  • New safety checks when you empty your trash – We now try to determine if the child attachments marked for removal are used anywhere else on your website. If they are, we do not remove them, to prevent broken links.
  • New option under Settings > Media to disable the extra checks for improved performance on large websites with thousands of posts and media files. (where you might experience slow queries and timeouts when you empty your trash)

Other important considerations

  • With the new safety checks enabled it’s fairly safe to reuse attachments between posts. But please, keep in mind, they are not fool-proof, especially if you store media file IDs or URLs in custom fields. That’s why we recommend you avoid reusing your attachments between posts, if possible.
  • If you need to use an attachment over and over again, upload it from the global Media Library menu ( Media > Add New ). This way, it won’t be attached as a child to a specific post, page, or custom post type.

Version 1.1.2

  • New filter added to allow developers define custom rules for controlling when the child attachments should be removed automatically
  • Removed the old ‘autoremove_attachments_post_types’ filter in favor of the new one – instructions available in FAQ

Version 1.1.1

  • New filter added to allow developers to change for what post types the child attachments should be removed automatically ( see FAQ for instructions )
  • Fixed a minor incompatibility with WP-Sweep

Version 1.1.0

  • Minor improvements for the admin notice

Version 1.0.9

  • Performance improvements on websites with a large number of posts and attachments

Version 1.0.8

  • Added extra security checks before the removal of attachments
  • Added an admin notice with a warning about the limitations of this plugin and the consequences of its improper usage. ( for new users only )

Version 1.0.7

  • Minor code refactoring
  • Added full support for WordPress Multisite

Version 1.0.6

  • Code refactored using wpcs

Version 1.0.5

  • Improved the warning displayed when very old PHP versions are used

Version 1.0.4

  • Remove all options on uninstall, even for multisite

Version 1.0.3

  • Added a security check to avoid deleting attachments when the ID of the parent post is invalid

Version 1.0.2

  • Fixed a bug that was causing media files to be removed when revisions were deleted with wp-cron

Version 1.0.1

  • Minimum required version of PHP set to 5.3

Version 1.0.0

  • 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…