i need to create new script if the image not present in real folder and not in used than delete from cache folder


Cach folder image



if this image not present in => "pub/media/catalog/product/"

than delete from => "pub/media/catalog/product/cache"

this kind of script i need to create can any one help me how can i archive this

1 Answer 1


First of all, you have to take a backup for the media folder and there is a way to delete unused images is using a module. Here is one that you can use. It is not risk-free, so do a backup first. You can use it from Github free.

reference: https://jvmsaas.com/support-en/magento-2-delete-unused-product-images-without-extension

Github : https://github.com/Vendic/EAVCleaner

  • can this module delete images from cache folder ?
    – Jay Parmar
    Sep 30, 2021 at 5:01
  • I did not try but you can check that module from the above link and check useful commands there. Sep 30, 2021 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.