Delete All Product Images from Magento 1

Spread the love

Need to remove all product images from your Magento site? Want to do a site-wide product image resize to speed up your size?
Below are some ways we can accomplish this.

Remove the image product association from database

This is probably the fastest way to remove all product images for a Magento site, just follow below steps:
Truncate (delete all records from) the two tables in your db: catalog_product_entity_media_gallery, catalog_product_entity_media_gallery_value

Magento saves all product image data at those tables. catalog_product_entity_media_gallery table stores image path info,

Magento product image db table

and catalog_product_entity_media_gallery_value table holds the image order and if the image is disable.
Magento product image db table

Just log into phpMyAdmin or use MySQL console to run the SQL statement below.

Then log into Magento backend, reindex and it;s done. However this method will not delete the initial images you uploaded before. These images file will remain in media/catalog/product. You can manually delete them or use the script below to delete the image from db and file system at the same time.

Remove images and delete image files

You can run a php script, which uses Magento APIs to remove assigned images for all products, and also delete the image files on the server.

Setp 1. Create a PHP file at your Magento installation root, name it delete_image.php

Step 2. Copy and paste the code below to the PHP file

Step 3. run and execute the PHP script at www.yourmagentodomain.com/delete_image.php

This may take a bit while if you have a large catalog due to I/O tasks involved.

Also, Remember to flush the catalog image cache. System > Cache Management > Flush Catalog Images Cach

Leave a Reply

Your email address will not be published. Required fields are marked *