• Can someone advise me on how to bulk delete images of removed products from the media library? I tried using Media Cleaner, but it ended up deleting images of products that are still listed, causing a major issue. Upon investigating the cause, it appears that some images in WooCommerce, despite being used and displayed, have their file status showing as unattached. When using Media Cleaner, these images get deleted.

    Until now, I haven’t had a method to delete large numbers of these images, so I’ve been leaving them as is. However, due to my business model of dealing with a large volume of used products that are typically sold only once, I need to regularly remove sold product listings. The problem is that WooCommerce doesn’t automatically delete the image files from the media library when a product is removed. As a result, the size of images from deleted products has become enormous, and I’m approaching the limit of my disk space.

    Is there a safe way to bulk delete these unused images without affecting the images of current products?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter yosukesuzuki

    (@yosukesuzuki)

    Does anyone have any good ideas? What I’m currently considering is a process to check images that are being used but for some reason are in an unattached state, to see if they’re being used in WooCommerce, and if so, to modify their state to attached.

    Thread Starter yosukesuzuki

    (@yosukesuzuki)

    Did I perhaps ask my question in the wrong place? This is the WooCommerce support forum, right??

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @yosukesuzuki

    Did I perhaps ask my question in the wrong place? This is the WooCommerce support forum, right??

    Yes, this is WooCommerce support forum and you’ve asked in the right place.

    Can someone advise me on how to bulk delete images of removed products from the media library?

    Unfortunately, WooCommerce doesn’t automatically delete images when a product is deleted. It’s also not possible to identify which images were used for which product after deleting. However, I can suggest a workaround that might help you.

    You can add the code snippet shared here to your child theme’s functions.php, which will delete all associated images once you remove a product.

    Alternatively, if you’re more comfortable using a plugin, consider installing and activating the Delete product images for WooCommerce plugin.

    Furthermore, since you’ve already deleted your product, you can use a plugin like Media Hygiene to clean up your unused media library and manage your disk space more effectively.

    I hope this helps! Please let us know how it goes or if you need further assistance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.