Jump to content
Sign in to follow this  
stragami

Remove Unused Images

Recommended Posts

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

 

settings:

$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>
</a></div><br><br>";

 

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

Share this post


Link to post
Share on other sites

:D THANK YOU SO MUCH PYRAMIDS!! (AKA Jeff)

 

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

 

Lee

Share this post


Link to post
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 ?

Share this post


Link to post
Share on other sites

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!!!

Share this post


Link to post
Share on other sites

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:

filename1.jpg

filename1.jpg.thumb_120x90.jpg

filename1.jpg.thumb_240x180.jpg

 

(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)
{
 $dp=opendir($dir);
 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
}

Share this post


Link to post
Share on other sites

 

 

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


Sam

 

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

 

Contributions:

 

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×