Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Remove Unused Images


Recommended Posts

I fixed my problem: This is what I had to do:



$root_dir = '/home/username/public_html/gifts';

// This is the actual SERVER address of your website. The final '/images' will be added automatically.



$base_dir = 'http://gifts.houseofrays.com'; // The URL for your website/catalog.


This information can be found in your catalog/admin/includes/configure.php file. Look for:

define('HTTP_CATALOG_SERVER', 'http://gifts.houseofrays.com');

define('DIR_FS_DOCUMENT_ROOT', '/home/username/public_html/gifts/');

define('DIR_FS_CATALOG', '/home/username/public_html/gifts/');


In the section dealing with the rename image buttons around line 332 I had to remove "admin" from a href=\"admin/remove_unused_images.php#button\"

$msg .= "<a name=button></a><a name=end></a><br><div align=center><a href=\"remove_unused_images.php#button\" onClick=\"select_all('checked_unused_images', '1');\"><font size=2><b>Check All Boxes</b></font></a><font size=2> | </font><a href=\"remove_unused_images.php#button\" onClick=\"select_all('checked_unused_images', '0');\"><font size=2><b>Uncheck All Boxes</b></font>


In name of script section, I also had to remove admin infront of remove_unused_images.php

// name of this script

$script_name = "remove_unused_images.php";


Hope this help others with same problems

Link to comment
Share on other sites

  • Replies 80
  • Created
  • Last Reply

Top Posters In This Topic



This contribution needed a little tweaking and cleaning to get it working smoothly for me, but this tool is awesome.


I've just got rid of 16000 unused product images and kept the 4000 that I need. Reason I had uploaded so many in the first place was due to the supplier providing a product CD that was so tightly integrated, yet poorly formatted.


But this contribution along with Easypopulate makes even the largest of databases easy to trim to size.


I've made many of the mod's discussed in here (such as the #UNUSED_ prefix, to list the files first in FTP - and removing the surplus "/admin/" links that break the various buttons). So I will upload the modified files as a package for anyone who needs them.


Thanks again



Link to comment
Share on other sites

I just installed the latest version (June 27th upload #2) When I click on the image link in the report, it adds 'admin' in the url for the images and so all the image links are broken. What do I need to change so that when I click on the image urls in the report, it works ?

Link to comment
Share on other sites

  • 2 months later...

Great contribution!!


I noticed that if you store your default images in the image folders (header.jpg, oscommerce.gif, oscommerce.jpg, images of mfgs, etc), this program won't recognize that these images are being used in the design elements of your site. So keep that in mind. If you are using your credit card logo, paypal logo, etc, all of these will be eaten alive by this script as not found as used in the product database....


Secondly, we tried to use the script. It found 18,162 products with images, 42,941 in images on server, and recommended deletion of 30,773. if I select all and process it goes to a blank page. It's not timing out, it does it immediately. If I hand select a few hundred and process, it works fine. Is there a way of


a) deselecting items used or called in site design presentation


B) addressing this issue of not processing. Our images are stored in a folder call master_images and I have changed the one reference in the file to master_images. I am just wondering if the script doesn't like that many files or if that is too big of a number to process with this script. Its not a php.ini limit, I changed that on server so its not a limit issue on server this is script specific.


Thanks and keep up the great work!!!

Link to comment
Share on other sites

  • 3 months later...

I have a problem... I am helping a friend with her shop and I installed this contrib to help her with all of her unused images. But...


She has a lot of thumbnail images with the pattern:





(stupid, I know)


As far as I can see, the function GetImageListFromServer finds the filename by stopping at the first occurance of "jpg", which makes it impossible to exclude all images with the pattern "thumb" for example. It only finds "filename1" in all three example files in my example. I am no php wizard, so I don't know how and where to edit the code...


function GetImageListFromServer($dir,&$files)
 while (false!=($file=readdir($dp)))
// ******** AZERISH enleve gifs		if( strpos($file, 'jpg') || strpos($file, 'gif') || strpos($file, 'png') ){
	if( strpos($file, 'jpg')  ){
	$locn = $dir.'/'.$file;
	$str = sprintf("%s", $locn);
       $files[] = $str;
 closedir($dp);//close the folders

Link to comment
Share on other sites



All that does is check the image type (ish) it does not split it, have you set $pattern as advised?



Remember, What you think I ment may not be what I thought I ment when I said it.




Auto Backup your Database, Easy way


Multi Images with Fancy Pop-ups, Easy way


Products in columns with multi buy etc etc


Disable any Category or Product, Easy way


Secure & Improve your account pages et al.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...