Guest lauriex Posted March 28, 2007 Share Posted March 28, 2007 Is there a way to prevent CubeCart from recreating a product thumbnail every time a product is updated in the Admin Edit Product? I have generated my own thumbs that I do not want to be overwritten by CubeCart - they are a different proportion and scale than the product photos used in the product pages. Quote Link to comment Share on other sites More sharing options...
Guest oldboy Posted March 28, 2007 Share Posted March 28, 2007 Thats a very good question, i would also like to know the answer. Quote Link to comment Share on other sites More sharing options...
markscarts Posted March 29, 2007 Share Posted March 29, 2007 I don't think CC will re-create a thumb if the thumb exists. Of course, the thumb must have the exact same name and image type as the main product, with the "thumb_" prefix. If, when you edit the prod, you are changinng the image, then of course it will create a new thumbnail. This is not to say that you cannot have a totally different thumbnail image, though, than main prod image. Here's how. 1. Add or edit your prod and be sure you add the image you want to use for prod. 2. Create your differing thumb on your PC, and give it the same name as prod image, addint the thumb_ prefix. example - for a prod image of widget.jpg, create a thumb_widget.jpg 3. Once you have all your differing thumbnails prepared, upload them via ftp to images/uploads/thumbs overwriting the onnes CC reated. Quote Link to comment Share on other sites More sharing options...
Guest lauriex Posted March 29, 2007 Share Posted March 29, 2007 I don't think CC will re-create a thumb if the thumb exists. Of course, the thumb must have the exact same name and image type as the main product, with the "thumb_" prefix. If, when you edit the prod, you are changinng the image, then of course it will create a new thumbnail. This is not to say that you cannot have a totally different thumbnail image, though, than main prod image. Here's how. 1. Add or edit your prod and be sure you add the image you want to use for prod. 2. Create your differing thumb on your PC, and give it the same name as prod image, addint the thumb_ prefix. example - for a prod image of widget.jpg, create a thumb_widget.jpg 3. Once you have all your differing thumbnails prepared, upload them via ftp to images/uploads/thumbs overwriting the onnes CC reated. Thanks! I have done steps 1- 3, and when I edit a product, even if no actual change is made and I click on Admin "edit product", CC auto-recreates and replaces (changes it back) the thumb I have created locally and uploaded. I can tell that it has been replaced by different width & height, throwing off my display, in addition to new thumb file creation date. You can see the result. Then I have to go in and reupload/replace my local copy of the thumb I want each time an edit is made. I have attached a screenshot where prod in row 2 column 2 has been replaced by CC. Quote Link to comment Share on other sites More sharing options...
Guest Posted March 29, 2007 Share Posted March 29, 2007 Laurie; Can you not protect the thumbnail folder (CHMOD it) once you upload it with your custom images? That way, when CC tries to update with a new thumbnail, it cant. Also, did you manage to get the image slined up? I wasn't able to get an answer to you over the weekend. Quote Link to comment Share on other sites More sharing options...
Guest lauriex Posted March 29, 2007 Share Posted March 29, 2007 Laurie; Can you not protect the thumbnail folder (CHMOD it) once you upload it with your custom images? That way, when CC tries to update with a new thumbnail, it cant. Also, did you manage to get the image slined up? I wasn't able to get an answer to you over the weekend. Hmm change folder permissions, didn't think of that. I remember changing specific folder/file permissions to writable (777) during install but what is the number I should change the thumbs folder back to? I will have to test whether this causes an error in CubeCart when it can't write to it's destination. As you have seen from my other post, my sales page alignment is still an issue. Thanks! Quote Link to comment Share on other sites More sharing options...
Guest oldboy Posted April 16, 2007 Share Posted April 16, 2007 Still no fix for this Recreating Thumbnail problem? As stated to change the permissions will not help Quote Link to comment Share on other sites More sharing options...
Guest Posted April 17, 2007 Share Posted April 17, 2007 Well, I've never fooled with this, but it looks like you need to change admin/products/index.php Around line 487, I found: // if image is a JPG check thumbnail doesn't exist and if not make one $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_POST['imageName'])); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){ if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'])){ @chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'], 0775); unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName']); } $thumb=new thumbnail($GLOBALS['rootDir']."/images/uploads/".$_POST['imageName']); $thumb->size_auto($config['gdthumbSize']); $thumb->jpeg_quality($config['gdquality']); $thumb->save($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName']); } You might try commenting out part of this - the middle section if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'])){ @chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'], 0775); unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName']); would be my first best guess. You might need to readjust the { } to avoid syntax errors, but this would be my best suggestion. Perhaps a better coder can give you more details. Quote Link to comment Share on other sites More sharing options...
Guest oldboy Posted April 22, 2007 Share Posted April 22, 2007 This code is on line 184 in my index.php Im not sure how to comment out the code u suggest, see code below what i did. // if image is a JPG check thumbnail doesn't exist and if not make one $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_POST['imageName'])); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)) comment start -- > //[/color] { // if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'])){ // @chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'], 0775); // unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName']); comment end -- > //[/color] } $thumb=new thumbnail($GLOBALS['rootDir']."/images/uploads/".$_POST['imageName']); $thumb->size_auto($config['gdthumbSize']); $thumb->jpeg_quality($config['gdquality']); $thumb->save($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName']); } This gave me a syntax error: Parse error: syntax error, unexpected '}' in /home/teclaste/public_html/dap/admin/products/index.php on line 269 Quote Link to comment Share on other sites More sharing options...
Guest Brivtech Posted April 22, 2007 Share Posted April 22, 2007 That's because there's a logic condition that you commented out, but the parser came across a terminator that shouldn't be there (Because you didn't comment the } at the end!). In php, when you have a logic arguement, the resulting condition allows for a block of code to be executed. This is wapped between { and }, before the condition finishes, or changes. Always count them to make sure the opening and closing curly brackets always match up. An easier way to comment out a whole section is to use /* and */ - It'll even cover the existing comment lines. In the code Mysty gave, use /* // if image is a JPG check thumbnail doesn't exist and if not make one $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_POST['imageName'])); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){ if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'])){ @chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName'], 0775); unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName']); } $thumb=new thumbnail($GLOBALS['rootDir']."/images/uploads/".$_POST['imageName']); $thumb->size_auto($config['gdthumbSize']); $thumb->jpeg_quality($config['gdquality']); $thumb->save($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$_POST['imageName']); } */ You could of course include a form option in admin/products/index.php, creating a variable say $doThumbRegen (set at default of 0 - NO), and then add in a condition at the beginning of the above block of code to see if it's set to 1 (yes), where it will execute the code, otherwise, skip over it. In practice, that there would be a radio button that says "Regenerate thumbnail on update", always set to NO, and if you want to generate it on any occasion (like when creating a product), you will need to manually set it to yes. Quote Link to comment Share on other sites More sharing options...
Guest oldboy Posted April 22, 2007 Share Posted April 22, 2007 Mysty and Brivtech you are my heroes.... This tweak saves me alot time. Before i had to upload the thumbs after any change on a product. Brivtech, no more syntax error when commenting the whole block of code... also /* and */ workes much better. Maybe time for a sticky here .. Quote Link to comment Share on other sites More sharing options...
Guest lauriex Posted April 25, 2007 Share Posted April 25, 2007 MYSTY and BRIVTECH, I can't thank you both enough for your contributions to this fix - it works beautifully and will save me tons of future headaches !!! Quote Link to comment Share on other sites More sharing options...
Guest Posted April 26, 2007 Share Posted April 26, 2007 No problem and glad I could help. Will accept donations of money saved on aspirin :( 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.