Bojanstven Posted July 19, 2017 Share Posted July 19, 2017 How can it be that PrestaShop doesn't have the simplest feature to delete all images at once? Let's say you have products with over 100 or 200 images and you accidentally upload wrong ones. So now you just need to delete the wrong 100 or 200 ones and upload the correct ones? But there is no button or feature "Delete all product images"?? For crying out loud... So you have to go about and click each product image by hand, manually every single one... Just makes no sense... Sure you can maybe create a copy of the product and then upload your new images there, but then you lose URL to that old product. But you can always change the URL? No, no you can't, because PrestaShop isn't WordPress.... Dang... Don't get me wrong, I love PrestaShop, it's just that some necessary features are missing even though Presta release version 1.7 with bells and whistles... Frustratingly irritating to delete all images by hand... Presta, please add this simple feature. Link to comment Share on other sites More sharing options...
Scully Posted July 26, 2017 Share Posted July 26, 2017 Having 100 or 200 images for one product is just too far away from a standard setup. Most shops provide between one and five images. Link to comment Share on other sites More sharing options...
Ivan Posted September 12, 2018 Share Posted September 12, 2018 I have same question, I'm new in prestashop, use csv to importar all products and combinations. I didn't prestashop maka every time a copy of image that you upload. So, I need to remove all image from products that i have tested. But I don't want to delete products. Is it possible? Don't understand why is not possible throught prestashop dashboard to remove multiple image. Link to comment Share on other sites More sharing options...
Mike Storey Posted October 17, 2018 Share Posted October 17, 2018 Hi, I have just done a search for this thread and after finding no helpful information, i have come up with an option that you can use to remove all images files and from the database. I use Store manager for Prestashop anyway for importing etc so i already had the software. But this software is very handy to have for importing etc. Step 1 - Delete images from inside p folder under img Step 2 - Open Store Manager and run Store Diagnostics under Tools Tab with only Images - Missing product images ticked. Step 3 - Select all and click delete Broken Record. You can then re import images, or add multiple images via a CSV or a standard excel sheet. Hope this helps. Link to comment Share on other sites More sharing options...
Simetria Posted October 23, 2018 Share Posted October 23, 2018 (edited) Mike Storey, what version of Prestashop are your instructions for? I cannot find anything for "Store Diagnostics" for version 1.7.x I too, am looking for a fast way to delete all the images at once for PS 1.7 Edited October 23, 2018 by Simetria (see edit history) Link to comment Share on other sites More sharing options...
mikestorey21 Posted October 24, 2018 Share Posted October 24, 2018 Hi Simetria, You have to have "Prestashop Store Manager" - https://www.prestashopmanager.com/ The version i have at the moment is 1.7.4.2 but works on anything from 1.4 to 1.7 with there software. Link to comment Share on other sites More sharing options...
javitxu Posted May 24, 2020 Share Posted May 24, 2020 Hi I use imacros Chrome extension. Easy and without a module: Record the steps to delete the first image play the recorded macro and all images will be deleted of the product 1 Link to comment Share on other sites More sharing options...
hshaker Posted September 24, 2021 Share Posted September 24, 2021 <?php ####PUT THIS FILE INTO YOUR MAIN SHOP FOLDER#### // root path of the shop, almost no one needs to change something here. $shop_root = $_SERVER['DOCUMENT_ROOT']."/"; // need to have slash / at the end $image_folder = 'img/p/'; // also needs slash at the ennd $scan_dir = $shop_root.$image_folder; include_once($shop_root.'config/config.inc.php'); include $shop_root . 'config/settings.inc.php'; #---------------------------------------------# $last_id = (int)Db::getInstance()->getValue(' SELECT id_image FROM '._DB_PREFIX_.'image ORDER BY id_image DESC '); $counted_images = Db::getInstance()->executeS(' SELECT count(*) as qnt FROM '._DB_PREFIX_.'image '); $counted_images = (int)$counted_images[0]['qnt']; echo 'There was '.$last_id.' images in database but only '.$counted_images.' is used right now. Lets check how many of them are eating up our storage without no reason.<br>'; //$limit = 150; // for testing $limit = $last_id; // for production $removed_images = 0; for ($i=1; $i <= $limit; $i++) { if (!imageExistsInDB($i)){ $imageDir = str_split($i); $imageDir = implode('/', $imageDir); $path = $scan_dir.$imageDir; deleteImagesFromPath($path); } } function deleteImagesFromPath($path) { global $removed_images; $images = glob($path . '/*.{jpg,png,gif,jpeg}', GLOB_BRACE); if ($images){ foreach ($images as $file) { if (is_file($file)) { unlink($file); } } $removed_images++; echo 'Deleted images from folder ' . $path . '/' ."<br/>"; } } function imageExistsInDB($id_image){ return Db::getInstance()->getValue(' SELECT id_image FROM '._DB_PREFIX_.'image WHERE id_image = '.(int)$id_image ); } echo '--------------------------------------<br>'; if ($removed_images > 0) echo 'Hurray! We removed '.$removed_images.' product images!'; else echo 'Everything is ok with Your images. I did not removed any of them or I made it before. Good Job Presta!'; http://yourshop.dtl/remove_unused_images.php It Work for me Link to comment Share on other sites More sharing options...
andreasbarner Posted October 5, 2021 Share Posted October 5, 2021 Hi, Guys! I am in the same situation. I want to clean out the image folder /p to get rid of all images in one step and to re-import them in the second step in better quality and adapted/corrected file names. I made the experience that PRESTASHOP does not delete product images consequently after I deleted a product. Actually I have 18000 products listed in average with 1 to 8 images. I want group them now in father-child-products and will be able to reduce double uploaded files, when this is done. But doing this manually is impossible, so most of the offered solution and addons I can not use without getting mad and gracy the same day! Right now the TIDY tool of GREEN MOUSE https://codecanyon.net/item/prestashop-tidy/18965736?s_rank=13 helps me a lot to clean the database, to eliminate unused photos/carts and to set first image as title in a rush (happened quite often, never understood why) to keep number of files and webspace/database size small, but also this great tool does not offer the professional complete cleaning of the image folder /p in a way that the store doesn't crash. I am not sure, which images are stored there else.... Did anyone of you guys found a stable and reliable solution? Especially if you have connected your stor/s to a ERP system the re-import won't be a big problem and would avoid the lose of rankings. Please let me know, how you solved your problems! May be, you found the perfect tool for this? Thank you and best wishes for all of you! Andreas Link to comment Share on other sites More sharing options...
Daresh Posted October 5, 2021 Share Posted October 5, 2021 To delete images you can use the following code, just place the script in the root folder of the shop: <?php require_once('config/config.inc.php'); require_once('init.php'); $limit = 1; if (Tools::isSubmit('limit')) { $limit = (int) $limit; } $sql = 'SELECT `id_image` FROM `'._DB_PREFIX_.'image` LIMIT '.$limit; $res = Db::getInstance()->executeS($sql); if ($res) { foreach ($res as $row) { $imageId = $row['id_image']; echo $imageId.'<br/>'; $image = new Image($imageId); $image->delete(); } } And then visit the script in your browser. You can also add additional parameter to indicate how many images to delete at once, the default is 1. You do it this way: del-img.php?limit=100 del-img.php 2 Link to comment Share on other sites More sharing options...
andreasbarner Posted October 5, 2021 Share Posted October 5, 2021 50 minutes ago, Daresh said: To delete images you can use the following code, just place the script in the root folder of the shop: <?php require_once('config/config.inc.php'); require_once('init.php'); $limit = 1; if (Tools::isSubmit('limit')) { $limit = (int) $limit; } $sql = 'SELECT `id_image` FROM `'._DB_PREFIX_.'image` LIMIT '.$limit; $res = Db::getInstance()->executeS($sql); if ($res) { foreach ($res as $row) { $imageId = $row['id_image']; echo $imageId.'<br/>'; $image = new Image($imageId); $image->delete(); } } And then visit the script in your browser. You can also add additional parameter to indicate how many images to delete at once, the default is 1. You do it this way: del-img.php?limit=100 del-img.php 425 B · 1 download Hello, Daresh! Thank you so much for your fast and unexpected reaction. I will download and test your script, then I will be back to you with hopefully good news! 🙂 Till soon! Andreas Link to comment Share on other sites More sharing options...
andreasbarner Posted October 7, 2021 Share Posted October 7, 2021 Hi, Daresh! After I downloaded the file, I uploaded the file into the root of my PRESTASHOP installation. I changed the limit to 100, to 1000, to 10000, but it seems that nothing is going to happen. In the upper left corner the white screen shows a five digit number that changes with each pressing the return button. Did I used the script the right way? Thank you for your help and listen to you soon! Andreas Link to comment Share on other sites More sharing options...
Daresh Posted October 7, 2021 Share Posted October 7, 2021 That number is ID of the image that is being deleted. If it's only one then it means that the limit is not applied and is set to default 1. Try setting it directly in the script by changing this line: $limit = 1; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now