I need to remove duplicate product photos after an import. Thumbnails were imported as product photos.

The thumbnail filename is based off the main images filename, so I have:


I need a query to look at each products images, and when it finds a product with images like:


Then the xxxxt.jpg image is removed.

Any MySQL experts have any advice? Were using Magento 1.7


This was already taken care of with a module. Image Clean works with on up to 1.7 and is available over on Magento Connect as a free install.

I recommend it as your issue will be an ongoing one. Magento does not remove images when product are deleted so not only do you have this import issue to contend with every time something goes akilter, but you have an ongoing and never ending disk usage bloat as Magento's less than stellar housekeeping lets it pack on the poundage in unused images from long dead and removed product.

Note: no affiliation with the above mentioned module. However, having tried to go the scripting route to manage images, found that this developer produced a module that works simply and efficiently. Just don't let it delete your placeholder images for "No image found"

| improve this answer | |
  • 1
    That module just looks for images that are in the media folder but not assigned to a product. These images are assigned to products, so the module will do nothing for me. – PlacementEdge Sep 12 '13 at 3:05
  • Ok, you've got repeat images in the image gallery... You're right, this won't work. – Fiasco Labs Sep 12 '13 at 3:07
  • The information is contained in catalog_product_entity_media_gallery and catalog_product_entity_media_gallery_value as a starting point. – Fiasco Labs Sep 12 '13 at 3:13
  • there is extension available for that magentocommerce.com/magento-connect/… – Keyur Shah Mar 9 '15 at 18:49
  • Keyur Shah, that looks like it would have been what we needed! Too late now, for $5 that plugin is worth it. – PlacementEdge Mar 21 '15 at 22:39

Here is a free little script to take care of that.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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