shopgirl Posted June 13, 2010 Share Posted June 13, 2010 Can someone tell me how to omit the thumbnail section (on the product page) when my originally uploaded image is 300x300 or smaller? I did some customizations to my thumbnails already but I think I can make it work with help. I'd appreciate it.Also I'm interested in a second modification where it always hides the 'product cover' thumbnail? So that image doesn't count as a thumbnail, no matter what size the image is. So if that's the only pic, it won't show the thumbnail section at all.(Because I would then link the 300x300 size image to the big pic. Right now the 300x300 is shown as a thumbnail which looks silly when it's the only pic and looks silly at other times too.) Link to comment Share on other sites More sharing options...
rocky Posted June 14, 2010 Share Posted June 14, 2010 I'm not sure how you can tell the size of the original uploaded image, since the thumbnail image will always be the same size. You'd have to find a way to get the size of the non-thumbnail image. I can tell you how to remove the cover image from the thumbnails though. Change lines 216-226 of product.php from: foreach ($images AS $k => $image) { if ($image['cover']) { $smarty->assign('mainImage', $images[0]); $cover = $image; $cover['id_image'] = intval($product->id).'-'.$cover['id_image']; $cover['id_image_only'] = intval($image['id_image']); } $productImages[intval($image['id_image'])] = $image; } to: foreach ($images AS $k => $image) { if ($image['cover']) { $smarty->assign('mainImage', $images[0]); $cover = $image; $cover['id_image'] = intval($product->id).'-'.$cover['id_image']; $cover['id_image_only'] = intval($image['id_image']); } list($sourceWidth, $sourceHeight) = getimagesize('img/p/'.intval($product->id).'-'.$image['id_image'].'.jpg'); $image['width'] = $sourceWidth; $image['height'] = $sourceHeight; $productImages[intval($image['id_image'])] = $image; } and change lines 109-129 of product.tpl from: {if count($images) > 0} <!-- thumbnails --> {if count($images) > 3}{l s='Previous'}{/if} {foreach from=$images item=image name=thumbnails} {assign var=imageIds value=`$product->id`-`$image.id_image`} <a href="{$link->getImageLink($product->link_rewrite, $imageIds, 'thickbox')}" rel="other-views" class="thickbox {if $smarty.foreach.thumbnails.first}shown{/if}" title="{$image.legend|htmlspecialchars}"> <img id="thumb_{$image.id_image}" src="{$link->getImageLink($product->link_rewrite, $imageIds, 'medium')}" alt="{$image.legend|htmlspecialchars}" height="{$mediumSize.height}" width="{$mediumSize.width}" /> {/foreach} {if count($images) > 3}<a id="view_scroll_right" title="{l s='Other views'}" href="[removed]{ldelim}{rdelim}">{l s='Next'}{/if} {/if} to: {if count($images) > 1} <!-- thumbnails --> {if count($images) > 4}{l s='Previous'}{/if} {foreach from=$images item=image name=thumbnails} {if $image.id_image != $cover.id_image_only} {assign var=imageIds value=`$product->id`-`$image.id_image`} {if $image.width > 300 OR $image.height > 300} <a href="{$link->getImageLink($product->link_rewrite, $imageIds, 'thickbox')}" rel="other-views" class="thickbox {if $smarty.foreach.thumbnails.first}shown{/if}" title="{$image.legend|htmlspecialchars}"> {/if} <img id="thumb_{$image.id_image}" src="{$link->getImageLink($product->link_rewrite, $imageIds, 'medium')}" alt="{$image.legend|htmlspecialchars}" height="{$mediumSize.height}" width="{$mediumSize.width}" /> {if $image.width > 300 OR $image.height > 300} {/if} {/if} {/foreach} {if count($images) > 4}<a id="view_scroll_right" title="{l s='Other views'}" href="[removed]{ldelim}{rdelim}">{l s='Next'}{/if} {/if} Change [removed] to javascript followed by a : Link to comment Share on other sites More sharing options...
shopgirl Posted June 14, 2010 Author Share Posted June 14, 2010 Thank you!Hmm, on the other issue, it could check the size upon upload/save? And if it's small, don't bother making the 'bloated' version(s) with tons of whitespace around them? Then it could know that no thickbox size exists, just the 300x300, so skip the A HREF. Link to comment Share on other sites More sharing options...
rocky Posted June 14, 2010 Share Posted June 14, 2010 To not generate thumbnails for products with small images won't work, since you'll end up with a lot of broken links. I'd have to think about it, but it may be possible to get the original image size of the images in product.php then pass them into product.tpl. Link to comment Share on other sites More sharing options...
shopgirl Posted June 14, 2010 Author Share Posted June 14, 2010 For some reason the "{if $image.id_image != $cover.id_image}" doesn't change things for me. (The other two changes just being formatting.) I'm still seeing the "repeated" thumbnail of the cover image.For the other thing... well, I don't mean skip generating thumbnails. I mean skip generating the thickbox size. Right now say my original upload is 300x300 or 290x290... it makes it into the 'large.jpg' 300x300... then it makes a thickbox.jpg that's huge like 900x900 with all that 600 pixels of white around it. Link to comment Share on other sites More sharing options...
rocky Posted June 14, 2010 Share Posted June 14, 2010 You are right. I just tested my code and I made a mistake. It should be $cover.id_image_only not $cover.id_image. I've updated my code above. Link to comment Share on other sites More sharing options...
rocky Posted June 14, 2010 Share Posted June 14, 2010 I made another correction to my code above. The first line should be > 1, not > 0.I've written code that gets the size of the original image and passed it into product.tpl. Should the thumbnails be hidden only if there is one image and the original size of the image is 300 x 300 pixels or less? Link to comment Share on other sites More sharing options...
shopgirl Posted June 14, 2010 Author Share Posted June 14, 2010 It works, of course... cool I accidentally didn't change that >1 >0 part, lol.Yes, thumbs would be hidden in that case due to the first mod that you wrote (never have a thumb for that one main cover image).The difference would be... if it's 300x300 or less, don't put the thickbox link/popup. I guess that's the only difference. Link to comment Share on other sites More sharing options...
rocky Posted June 14, 2010 Share Posted June 14, 2010 I've updated the code above to remove the links from all thumbnails with images less than 300 x 300 pixels. Let me know if it works for you. Link to comment Share on other sites More sharing options...
shopgirl Posted June 14, 2010 Author Share Posted June 14, 2010 It's working! That's much nicer. Thanks again. Link to comment Share on other sites More sharing options...
rocky Posted June 14, 2010 Share Posted June 14, 2010 If your issue is resolved, please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
Saul Posted November 22, 2010 Share Posted November 22, 2010 This did not work for me. When I used this code and changed the attribute the image does not change. Is it possible to hide the thumbnails, and have attributes which change images.Saul Link to comment Share on other sites More sharing options...
lucane Posted February 9, 2012 Share Posted February 9, 2012 Does this work for 1.4.6.2? I can't even find the relevant product.php file, let alone the code within it that I am supposed to alter. Thank you for your assistance! Link to comment Share on other sites More sharing options...
lucane Posted February 10, 2012 Share Posted February 10, 2012 Can anyone get this to work in Prestashop 1.4? Link to comment Share on other sites More sharing options...
lucane Posted February 11, 2012 Share Posted February 11, 2012 I really cannot find the code that Rocky provided. Has it changed between versions? Can anyone provide me with some hints? Thank you. 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