Jump to content

Deleting Broken Images Automatically withn the Database


Recommended Posts

I uploaded thousands of products via a CSV file in a mass import.  For the CSV import, many of the products noted to have multiple images associated with them.  The reality is that most of these products only had one image.  This has left me with A LOT of my products showing one product image and then the question mark image for all of the other "missing images" on the frontend. 

 

Is there a way for me delete all "missing images" associated with a product for all products in mass?  It would take me forever to go into each and every product individually and manually delete the question mark images.​

Link to comment
Share on other sites

Thank you for the help!  Unfortunately, with some of the products...I only want to keep the cover photo.  However, on many of the products there are two or three legit photos that need to stay.  Therefore, I was hoping that there was a way to determine only the pictures that don't have URLs (the question mark images) and removed those.

Link to comment
Share on other sites

Then take this a little bit further and create a php script in which you select all the image ids from your store, use Image::getAllImages().

For every image id instantiate the class Image and test if file_exists(_PS_PROD_IMG_DIR_.$this->getImgFolder()), if the image doesn't exists use function delete() of class Image.

Link to comment
Share on other sites

Then take this a little bit further and create a php script in which you select all the image ids from your store, use Image::getAllImages().

For every image id instantiate the class Image and test if file_exists(_PS_PROD_IMG_DIR_.$this->getImgFolder()), if the image doesn't exists use function delete() of class Image.

 

I appreciate you taking the time to comment and help.  Unfortunately, I do not know php all that well to be able to write the script myself.

Link to comment
Share on other sites

  • 5 months later...

Hi - I need to delete all the product images from the site and start again as everytime I have uploaded a csv file is has regenerated a product image and I can't find a way to change this in bulk. I'm also getting an error 404 when I regenerate thumbnails.

 

Can you talk me through step by step how to do this? it looks like it could be similar to the solution above.

 

Can you help? thanks in advance - Susie ( beginner with little knowledge sadly)

Link to comment
Share on other sites

×
×
  • Create New...