stragami Posted November 10, 2008 Share Posted November 10, 2008 Hi Jeff, thanks for this Contrib, work fine....... now. But i habe a Tumbnailer installed and the this images will be add to the folder catalog/images/imagename-150x150 how i can exclude this kind of images from the list general rgds Alfred Quote Link to comment Share on other sites More sharing options...
pyramids Posted November 10, 2008 Share Posted November 10, 2008 If I understand what you are asking, look here: $images_dir = 'images'; // if you add more sub folders of $images_dir then edit as EX: $more_folders = array("thumb","full"); // you must make sure the corresponding tables are in $table_array $more_folders = array("thumb","full"); The sub image folder in the above array is set like images/thumb images/full change it to suit your setup You will also have to make sure the database is also reading the same images in the db array: $table_array = array("products_image","products_image_med","products_image_sm_1","products_image_xl_1","products_image_sm_2","products_image_xl_2","products_image_sm_3","products_image_xl_3","products_image_sm_4","products_image_xl_4","products_image_sm_5", "products_image_xl_5","products_image_sm_6","products_image_xl_6"); so make sure your db images can be found in the sub folders you list. Quote Link to comment Share on other sites More sharing options...
stragami Posted November 10, 2008 Author Share Posted November 10, 2008 Hi Jeff soory but this is not my problem, thumbs will be saved in the same folder catalog/images - to every pictures e.g 1234.jpg the thumbnailer will be added a file e.g. like this 1234-150x150.jpg in this caes all thumbs will be displayed for renameing. how i can exclude files like this 1234"-150x150" or -100x100 or what ever this size are from the list rgds alfred Quote Link to comment Share on other sites More sharing options...
pyramids Posted November 10, 2008 Share Posted November 10, 2008 ok, so you want to exclude a file. That is something that could be done, you would need to make an array of the excluded files and have them removed from the list Quote Link to comment Share on other sites More sharing options...
pyramids Posted November 10, 2008 Share Posted November 10, 2008 I had some time to do this... here are the changes to put in an file to exclude function add this at the top near the other variables: (change the MYFILE1, MYFILE2 to whatever) // exclude these image files $exclude_list_array = array('MYFILE1', 'MYFILE2'); change this: if($image_diff[$i]){ $msg .= '<a target="_blank" href="'.$images_dir.'/'.$image_diff[$i].'">'.$image_diff[$i].'</a> <input type="checkbox" name="checked_unused_images[]" value="'.$image_diff[$i].'"><br>';//unused images to rename checked to: if (ExcludeFile($image_diff[$i],$exclude_files)){ $msg .= '<a target="_blank" href="'.$base_dir.$images_dir.'/'.$image_diff[$i].'">'.$image_diff[$i].'</a> <input type="checkbox" name="checked_unused_images[]" value="'.$image_diff[$i].'"><br>';//unused images to rename checked add the function at the end function ExcludeFile($exfile,$exclude_files) { $hold_return = 0; $get_size = count($exclude_files); for ($i = 0; $i < $get_size; ++$i) { if( (strpos($exfile, $exclude_files[$i]))!== false ){ $hold_return ++; } } if($hold_return > 0){return false;}else{return true;} } Quote Link to comment Share on other sites More sharing options...
stragami Posted November 10, 2008 Author Share Posted November 10, 2008 Hi Jeff thanks for your work, but i think we talking about 2 diifertn points my problem is that 1 have always 2 file for each picture thats means that there are tousnds of pics inside i cant exclude all this pics by entering this into the arry that is the same work as i exclude them like now. it must be a arry with a * e.g. exclude all imges if they are endung with e.g -150x150 samples 1234.jpg 2345.jpg 3456.jpg the tumbs are 1234-150x150.jog 2345-150x150.jpg 3456-150x150.jpg what i need is to exclude all files ending with -150x150 hope i give you a clear understandung about my problem rgds alfred Quote Link to comment Share on other sites More sharing options...
pyramids Posted November 10, 2008 Share Posted November 10, 2008 the above update will do that. install the changes and then update $exclude_list_array as: // exclude these image files $exclude_list_array = array('150x150'); Quote Link to comment Share on other sites More sharing options...
stragami Posted November 11, 2008 Author Share Posted November 11, 2008 Did not work what ever i setup into the arry the thmubs will diplayed all the time rgds alfred Quote Link to comment Share on other sites More sharing options...
pyramids Posted November 11, 2008 Share Posted November 11, 2008 rename this variable $exclude_list_array to $exclude_files as I was testing I must have forgotten to change the code I posted so your new variable will look like: $exclude_files = array('150x150'); Quote Link to comment Share on other sites More sharing options...
stragami Posted November 11, 2008 Author Share Posted November 11, 2008 y´r a star! thanks for help works fine rgds alfred Quote Link to comment Share on other sites More sharing options...
stragami Posted November 13, 2008 Author Share Posted November 13, 2008 hi to install this contrib in root i m asking if this is a security risk? how i can start this from admin directory (or if io understand it worng? right now i test this only local by xampp but im unable to bring this into the admin panel thanks for help rgds alfred Quote Link to comment Share on other sites More sharing options...
pyramids Posted November 13, 2008 Share Posted November 13, 2008 for admin installation the instructions given with the mod are ... ################# # INSTALLATION: # ################# 1. Add this files into your admin directory: admin/remove_unused_images.php 2. In the admin/includes/filenames.php file add: define('FILENAME_REMOVE_IMAGES', 'remove_unused_images.php'); 3. In admin\includes\boxes\tools.php add: '<a href="' . tep_href_link(FILENAME_REMOVE_IMAGES, '', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_TOOLS_REMOVE_IMAGES . '</a><br>' . 4. In admin/includes/languages/english.php add: define('BOX_TOOLS_REMOVE_IMAGES', 'Remove Images'); 5. Set your admin file permissions for the Tools box if needed Note: when you click the link to load the page, right click and load in a new tab, since this mod doesn't load in a standard admin page. Quote Link to comment Share on other sites More sharing options...
stragami Posted November 13, 2008 Author Share Posted November 13, 2008 (edited) If i copy this to the admin side i also have to change the line 64,66 and 138 it is a local test only using Xampp line 64 - 66 $root_dir = 'c:/xampp/htdocs/os/catalog/admin'; $base_dir = 'http://127.0.0.1/os/catalog/admin'; // for links line 138 if (require ('c:/xampp/htdocs/os/catalog/admin/includes/configure.php')){}else{echo '<b>ERROR - could not locate the config file</b><br><br>';break;}// login info so it will works fine - it must be done also in the live shop im right? rgds alfred Edited November 13, 2008 by stragami Quote Link to comment Share on other sites More sharing options...
stragami Posted November 13, 2008 Author Share Posted November 13, 2008 (edited) This is not correct: correct one Line 64 $root_dir = 'c:/xampp/htdocs/os/catalog'; so the correct files will be displayed but in this case the call back funktion remove_unused_images.php#button does not work what i have to change else? if i change root into root_dir = 'c:/xampp/htdocs/os/catalog/admin the admin images will be selected without the funktion remove_unused_images.php#button does not work rgds alfred Edited November 13, 2008 by stragami Quote Link to comment Share on other sites More sharing options...
pyramids Posted November 13, 2008 Share Posted November 13, 2008 These 2 variables have nothing to do with the admin this is where the images are located $root_dir = '/home/USERNAME/public_html/catalog/'; // look in this root this is where the www link info is located $base_dir = 'http://www.MYDOMAIN.com/catalog/'; // for links Quote Link to comment Share on other sites More sharing options...
shadowvoice Posted November 18, 2008 Share Posted November 18, 2008 Hi All! First of all - many thanks to author for this contribution. Very usefull to bring all mess re pictures into order. :rolleyes: Instalation and implementation of latest amendments stated above went smoothly and painless - thks again ;-) Reget I can't get it renaming ANYTHING. "No boxes were checked, so nothing was done"! Nothing happens even after checking all boxes (manually and by check all): echo $count_diff_list brings 216, but... "No boxes were checked, so nothing was done"! Are where tomatoes growing in my eys that I can't find what's up? Any assistance/adivces welcome... <_< Quote Link to comment Share on other sites More sharing options...
pyramids Posted November 18, 2008 Share Posted November 18, 2008 it appears some code is missing? in remove_unused_images.pgp find: $msg_s = '<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head><title>Rename Unused Images</title></head><body><!-- body_text //--><table bgcolor="Lime" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center"><h2>Rename Images that are not being called from the Database</h2></td></tr></table><br><table width="80%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td valign="top"><b><font size="4">The images listed below were renamed</font></b><br><br>'; $hold_change = 0; change to: $msg_s = '<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head><title>Rename Unused Images</title></head><body><!-- body_text //--><table bgcolor="Lime" width="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td align="center"><h2>Rename Images that are not being called from the Database</h2></td></tr></table><br><table width="80%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td valign="top"><b><font size="4">The images listed below were renamed</font></b><br><br>'; $hold_change = 0; //added missing code line 311 $checked_unused_images = $HTTP_POST_VARS['checked_unused_images']; Let me know your results Quote Link to comment Share on other sites More sharing options...
shadowvoice Posted November 18, 2008 Share Posted November 18, 2008 Hi pyramids! Many thanks for solution - now works like hell! Simply perfect! You made me surpriced with so rapid reply - thks again. :lol: I also made small ammendement in php, which I'd suggest to include in next release: function GetImageListFromServer($dir,&$files) { $dp=opendir($dir); while (false!=($file=readdir($dp))) { if (strpos($file, 'jpg') OR strpos($file, 'gif')) { // Extended by Kirs to operate not only jpg but gif as well. $locn = $dir.'/'.$file; $str = sprintf("%s", $locn); $files[] = $str; } } closedir($dp);//close the folders } Regadrs, Kirs Quote Link to comment Share on other sites More sharing options...
mousewebdesign Posted November 18, 2008 Share Posted November 18, 2008 Hi Pyramide, thanx for the great contrib ! but I have a question: today you've uploaded a new version of the remove unused images (v1.0a but the old version was v1.1 ??) because you've added a line of code which can read the checkboxes. but it doesn't work. when pressing the 'check all boxes'-link, Internet Explorer gives a 'website cannot be found' error. could you please tell me what's wrong? marcus Quote Link to comment Share on other sites More sharing options...
pyramids Posted November 18, 2008 Share Posted November 18, 2008 When I get time - I need to update the instructions to be more exact, until then... instructions should be Install in the admin root as (mydomain.com/admin/remove_unused_images.php) The instructions mention running it in the shop root, that is how I first set it up, then I modified it to run in the admin. It actually can run anywhere in your site, but for security it should be the admin folder. Hope this helps. Quote Link to comment Share on other sites More sharing options...
Inferos Posted November 19, 2008 Share Posted November 19, 2008 (edited) First of all thanks for the splendid contrib! My question is what needs to be edited in order to delete the unused images? I noticed there's a mention of this being possible in the comments inside the file, but no idea how to do it. Normally for a few hundred products there's no problem connecting to ftp afterwords and deleting them, but in my case, there are more than 2000 pictures, some of which unused anymore, and most servers (through the ftp clients) are unable to list more than 2000 files, and truncate the listing to just about that. So basically there's no way to access (delete etc.) the files, other than manually delete them one by one through cPanel. Thanks! *later edit* I used a trick to be able to finish the job, changed the renaming mask to #UNUSED_ instead of UNUSED_, so all newly renamed files were listed on top of the list. This way I could connect through ftp and delete them with no problem. Edited November 19, 2008 by Inferos Quote Link to comment Share on other sites More sharing options...
circusboy Posted November 19, 2008 Share Posted November 19, 2008 You can also add gif files to the first (product database) list by adding to the amendment suggested by Kirs: { // Extended by Kirs to operate not only jpg but gif as well. on or around line 147, replace: if (strpos($image_info[$table_array[$i]], 'jpg')) with: if (strpos($image_info[$table_array[$i]], 'jpg') OR strpos($image_info[$table_array[$i]], 'gif')) //add gif to list Conceivably, if you also use png files, you could extend this to include them. Quote Link to comment Share on other sites More sharing options...
pyramids Posted November 19, 2008 Share Posted November 19, 2008 Similiar to above but in also in the shop list. If you want to update the script to find other images like gif and png make these changes: find: if (strpos($image_info[$table_array[$i]], 'jpg')) change to: if( strpos($image_info[$table_array[$i]], 'jpg') || strpos($image_info[$table_array[$i]], 'gif') || strpos($image_info[$table_array[$i]], 'png') ) find if (strpos($file, 'jpg')){ change to: if( strpos($file, 'jpg') || strpos($file, 'gif') || strpos($file, 'png') ){ Quote Link to comment Share on other sites More sharing options...
circusboy Posted November 19, 2008 Share Posted November 19, 2008 Hi All! First of all - many thanks to author for this contribution. Very usefull to bring all mess re pictures into order. :rolleyes: Instalation and implementation of latest amendments stated above went smoothly and painless - thks again ;-) Reget I can't get it renaming ANYTHING. "No boxes were checked, so nothing was done"! Nothing happens even after checking all boxes (manually and by check all): echo $count_diff_list brings 216, but... "No boxes were checked, so nothing was done"! Are where tomatoes growing in my eys that I can't find what's up? Any assistance/adivces welcome... <_< Something I find in my install is that the check all/uncheck all link doesn't go to the correct location. I have to add admin/ to the check/uncheck link. After I do that (on or around line 307) I can mouse over the link and see the correct path to my admin folder (which is within catalog). I changed: $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=4><b>Check All Boxes</b></font></a><font size=4> | </font><a href=\"remove_unused_images.php#button\" onClick=\"select_all('checked_unused_images', '0');\"><font size=4><b>Uncheck All Boxes</b></font> to: $msg .= "<a name=button></a><a name=end></a><br><div align=center><a href=\"admin/remove_unused_images.php#button\" onClick=\"select_all('checked_unused_images', '1');\"><font size=4><b>Check All Boxes</b></font></a><font size=4> | </font><a href=\"admin/remove_unused_images.php#button\" onClick=\"select_all('checked_unused_images', '0');\"><font size=4><b>Uncheck All Boxes</b></font> and the links worked. But now the button to change the names doesn't work! So around line 98, at the script name, I do this: // name of this script $script_name = "admin/remove_unused_images.php"; and life is good again. If your admin folder is somewhere else entirely, you can also define it at the top in the settings area: $admin_dir = 'admin/'; // for script location and then recode the above links for this scalar HTH - Joe Quote Link to comment Share on other sites More sharing options...
mousewebdesign Posted November 19, 2008 Share Posted November 19, 2008 Something I find in my install is that the check all/uncheck all link doesn't go to the correct location. I have to add admin/ to the check/uncheck link. After I do that (on or around line 307) I can mouse over the link and see the correct path to my admin folder (which is within catalog). I changed:$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=4><b>Check All Boxes</b></font></a><font size=4> | </font><a href=\"remove_unused_images.php#button\" onClick=\"select_all('checked_unused_images', '0');\"><font size=4><b>Uncheck All Boxes</b></font> to: $msg .= "<a name=button></a><a name=end></a><br><div align=center><a href=\"admin/remove_unused_images.php#button\" onClick=\"select_all('checked_unused_images', '1');\"><font size=4><b>Check All Boxes</b></font></a><font size=4> | </font><a href=\"admin/remove_unused_images.php#button\" onClick=\"select_all('checked_unused_images', '0');\"><font size=4><b>Uncheck All Boxes</b></font> and the links worked. But now the button to change the names doesn't work! So around line 98, at the script name, I do this: // name of this script $script_name = "admin/remove_unused_images.php"; and life is good again. If your admin folder is somewhere else entirely, you can also define it at the top in the settings area: $admin_dir = 'admin/'; // for script location and then recode the above links for this scalar HTH - Joe Hi Joe, thanx a lot !! it's working now... marcus Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.