WP Manifestindependent plugin directory
manifest / ecommerce / clean-up-product-images-for-woocommerce

Clean Up Product Images for WooCommerce

★ 1stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/wpspeedexpert/clean-up-product-images-for-woocommerce/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Automatically delete a product's attached images when the product is deleted in WooCommerce — while never removing an image that is still used by another product or post.


✅ Features

  • Deletes images attached to a WooCommerce product when that product is permanently deleted.
  • Shared-image safe: before deleting any image, it checks whether the image is still referenced elsewhere — as a featured image (_thumbnail_id), in a product gallery (_product_image_gallery), or embedded in another post's content — and skips it if so.
  • Runs automatically on the before_delete_post hook. No configuration required.
  • Lightweight — uses native WordPress / WooCommerce functions only.
  • Protects both manual product deletions and automated cleanups (e.g. Delete Old Out-of-Stock Products), since both trigger the same hook.

🧠 Why shared-image safety matters

Stores often reuse one image across many products — open-box / condition-variant listings, or distributor-synced catalogues. Deleting a shared image would strip the cover image from every product using it, because WordPress removes the _thumbnail_id reference from all posts when an attachment is deleted. This plugin prevents that by preserving any image still in use.


🔧 Installation

  1. Upload the plugin to /wp-content/plugins/ (or install via the Plugins admin).
  2. Activate it through the Plugins menu.
  3. Ensure WooCommerce is active. The plugin then works automatically in the background.

📝 Requirements

  • WordPress 5.2+
  • WooCommerce 4.0+
  • PHP 7.2+

❓ FAQ

Does it remove non-product media? No — only images attached to product posts.

What if an image is shared between products? It is kept. See Why shared-image safety matters above.

Can deleted images be recovered? No — deletion is permanent. Keep backups.


📋 Changelog

See CHANGELOG.md.


🧑‍💻 Credits

Developed by Gorilla DevOps.

📄 License

GPLv2 or later — see LICENSE.