mnmak Posted May 7, 2014 Share Posted May 7, 2014 Hi there, is it possible to have one image as a cover for an item when it is in a list, and another image for a cover when it is previewed or viewed? Said in other words the item to be seen with image #1 in the list and when opened(or previewed) Image #2 to load as cover.Thank you! Link to comment Share on other sites More sharing options...
Vire Posted May 7, 2014 Share Posted May 7, 2014 Yep thats possible. If u just rightclick on the category picture and on the large picture u notice that the category one is safed in home-default and the product in large-default so you can upload your pircute in that folder with the right size and use it. Its definitly not the easyest solution and im pretty sure there are other, easyer solutions. 1 Link to comment Share on other sites More sharing options...
mnmak Posted May 8, 2014 Author Share Posted May 8, 2014 Thank you for the advice mate, but it will be really hard having all the images in the correct sizing. Hope there will be easier way to do it... Link to comment Share on other sites More sharing options...
Vire Posted May 8, 2014 Share Posted May 8, 2014 Its a default sice you can set up in the BO by default this should be 250x250px so you can just resize it and upload it via ftp in the folder. But ye, properly there is a easyer way. Im not confident with the coding part and so on. Just searched a solution for you and found that out. Link to comment Share on other sites More sharing options...
mnmak Posted May 8, 2014 Author Share Posted May 8, 2014 Thanks Vire. There is another problem with this solution though, The images are not in a folder so I could switch them. I dont know how to explain this, but there is no folder(or file) in the location listed as URL. http://bgpokerclub.com/sangado/57-home_default/sredizemnomorski-briz.jpg for example, there is no directory 57-home_default... Link to comment Share on other sites More sharing options...
Vire Posted May 8, 2014 Share Posted May 8, 2014 (edited) Ah wait, let me check that. I got what you mean, needed some time for me to figure it out as well, used that solution to change the sub category icons. Ill respond to you shortly Okay i belive i got it. It should work like that /img/p p for product than you get numbers like 1,2,3,4 there the products get stored with the id. that means the first number so 57 should be stored in 5 than and the next number means the 2. number so 57 should be located in /img/p/5/7 and than you see all the images. Edited May 8, 2014 by Vire (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 8, 2014 Share Posted May 8, 2014 i've got an idea in my head with little modification of controller. but before i will write solution i have to ask about something. for a cover when it is previewed or viewed? you mean product page? or something else? Link to comment Share on other sites More sharing options...
mnmak Posted May 8, 2014 Author Share Posted May 8, 2014 i've got an idea in my head with little modification of controller. but before i will write solution i have to ask about something. you mean product page? or something else? I need one picture to be for cover when the product is seen in its category, when searched in a search list, and when seen in any other list, for example here - http://bgpokerclub.com/sangado/en/5-classic and another picture to be for cover, or default image, when the product is "opened" and seen here - http://bgpokerclub.com/sangado/en/classic/8-sredizemnomorski-briz.html Im sorry for the way I explain what I mean, but Im not sure of the proper terms and names... Link to comment Share on other sites More sharing options...
vekia Posted May 8, 2014 Share Posted May 8, 2014 ok, in productController paste this funciton public static function geImagesByID($id_product, $limit = 2){ $id_image = Db::getInstance()->ExecuteS('SELECT `id_image` FROM `'._DB_PREFIX_.'image` WHERE `id_product` = '.(int)($id_product) . ' ORDER BY position ASC LIMIT 1, ' . $limit); $toReturn = array(); if(!$id_image) return; else foreach($id_image as $image) $toReturn[] = $id_product . '-' . $image['id_image']; return $toReturn; } then in product.tpl file you can use: {assign var="pImages" value=ProductController::geImagesByID($smarty.get.id_product,1)} {if $pImages} {foreach from=$pImages item=image name=images} <img src="{$link->getImageLink($product->link_rewrite, $image, 'large_default')}" alt="{$product->legend|escape:'htmlall':'UTF-8'}" /> {/foreach} {/if} to display second image instead of original one :-) 1 Link to comment Share on other sites More sharing options...
mnmak Posted May 8, 2014 Author Share Posted May 8, 2014 Thank you very much Vekia, have a lame question though . Where do I find the product.tpl file? I found a couple of them in different folders, cant decide which one is the one I need to edit. Does it matter where in the body I paste the additional code? As for the "then in product.tpl file you can use:", just to make sure, u mean as for productController, to add this code to it? Thanks again and sorry for my silly questions. Link to comment Share on other sites More sharing options...
vekia Posted May 8, 2014 Share Posted May 8, 2014 product.tpl file is a file located in your theme directory. themes/your-theme/product.tpl your-theme is a name of theme that you currently use regarding to other questions paste this code: public static function geImagesByID($id_product, $limit = 2){ $id_image = Db::getInstance()->ExecuteS('SELECT `id_image` FROM `'._DB_PREFIX_.'image` WHERE `id_product` = '.(int)($id_product) . ' ORDER BY position ASC LIMIT 1, ' . $limit); $toReturn = array(); if(!$id_image) return; else foreach($id_image as $image) $toReturn[] = $id_product . '-' . $image['id_image']; return $toReturn; } before last closing bracket in controllers/front/ProductController.php file 2 Link to comment Share on other sites More sharing options...
mnmak Posted May 8, 2014 Author Share Posted May 8, 2014 Ok, added the code. It works in a bit different way though. Please take a look - http://bgpokerclub.com/sangado/bg/cvetna-kolekciya/16-blgarska-roza.html . The second image is over the first one in the top. it is the same and in "quick preview" . Thank you. Link to comment Share on other sites More sharing options...
vekia Posted May 8, 2014 Share Posted May 8, 2014 you replaced original code with code that i suggested to use in tpl file? it looks like not :-) Link to comment Share on other sites More sharing options...
mnmak Posted May 8, 2014 Author Share Posted May 8, 2014 you replaced original code with code that i suggested to use in tpl file? it looks like not :-) Yep, got it wrong - I just added, didnt replaced. Link to comment Share on other sites More sharing options...
mnmak Posted May 8, 2014 Author Share Posted May 8, 2014 (edited) Vekia, I couldnt figure it out which part of the code in product.tpl I need to replace with the code u gave me. There is no line starting with " {assign var="pImages""... Edited May 8, 2014 by mnmak (see edit history) Link to comment Share on other sites More sharing options...
mnmak Posted May 10, 2014 Author Share Posted May 10, 2014 (edited) Still cant figure it out... Edited May 10, 2014 by mnmak (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 10, 2014 Share Posted May 10, 2014 sorry for late reply, im back in product.tpl you can find code: <span id="view_full_size"> {if $jqZoomEnabled && $have_image && !$content_only} <a class="jqzoom" title="{if !empty($cover.legend)}{$cover.legend|escape:'html':'UTF-8'}{else}{$product->name|escape:'html':'UTF-8'}{/if}" rel="gal1" href="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'thickbox_default')|escape:'html':'UTF-8'}" itemprop="url"> <img itemprop="image" src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'large_default')|escape:'html':'UTF-8'}" title="{if !empty($cover.legend)}{$cover.legend|escape:'html':'UTF-8'}{else}{$product->name|escape:'html':'UTF-8'}{/if}" alt="{if !empty($cover.legend)}{$cover.legend|escape:'html':'UTF-8'}{else}{$product->name|escape:'html':'UTF-8'}{/if}"/> </a> {else} <img id="bigpic" itemprop="image" src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'large_default')|escape:'html':'UTF-8'}" title="{if !empty($cover.legend)}{$cover.legend|escape:'html':'UTF-8'}{else}{$product->name|escape:'html':'UTF-8'}{/if}" alt="{if !empty($cover.legend)}{$cover.legend|escape:'html':'UTF-8'}{else}{$product->name|escape:'html':'UTF-8'}{/if}" width="{$largeSize.width}" height="{$largeSize.height}"/> {if !$content_only} <span class="span_link no-print">{l s='View larger'}</span> {/if} {/if} </span> instead of read code use code that i suggested to use in tpl file enjoy the changes Link to comment Share on other sites More sharing options...
mnmak Posted May 10, 2014 Author Share Posted May 10, 2014 (edited) Thanks Vekia, it is working, but only in quick preview. Here it is what I got as result. 1. In Quick Preview it loads the 2nd Image as cover, but it seems to disable the other 2 images - they are there but can not be selected and viewed in the "main image spot" 2. In regular(full) product view it doesnt seem to work - 1st Image is still opened as cover. Here is a link to my shop. Thank you. UPDATE: The above is true with JqZoom ENABLED(which is my default setup). Here is the result after disabling the JqZoom: 1. No changes here - In Quick Preview it loads the 2nd Image as cover, but it seems to disable the other 2 images - they are there but can not be selected and viewed in the "main image spot" 2. In regular(full) product view, Image 2 is loaded as cover. Clicking on images 1 or 3 loads them directly in "full size", instead of getting them in the place of the cover image. When click on the cover - image 2 - it loads image 1 in full size mode. Edited May 10, 2014 by mnmak (see edit history) Link to comment Share on other sites More sharing options...
mnmak Posted May 14, 2014 Author Share Posted May 14, 2014 Please help Link to comment Share on other sites More sharing options...
bulla101 Posted March 22, 2015 Share Posted March 22, 2015 Hi, trying to use this code with changing the default image on a product page to the 2nd image. It only partly works, it will correctly load the 2nd image by default, but the rollover on the thumbnails no longer works? Any one able to help? Prestashop 1.6.0.11 Link to comment Share on other sites More sharing options...
Martino00 Posted June 30, 2015 Share Posted June 30, 2015 Indeed bulla101. Vekia's code seems to work but the rollover is not working. And there is also a problem if you only have one image for your product. Link to comment Share on other sites More sharing options...
bulla101 Posted August 9, 2015 Share Posted August 9, 2015 Hi all, does anyone know how to get this working in version 1.6.1.0? I've just updated my store and the value part below that worked in 1.6.0.14 crashes my product template and nothing will load. "{assign var="pImages" value=ProductController::geImagesByID($smarty.get.id_product,1)}" Link to comment Share on other sites More sharing options...
bulla101 Posted August 12, 2015 Share Posted August 12, 2015 bump Does anyone know why this would not be working in the new version of Prestashop? Link to comment Share on other sites More sharing options...
PSBarcelona Posted February 11, 2016 Share Posted February 11, 2016 Great solution. It's working on PS 1.6.1.3 Anybody knows how to convert the product page images in a slideshow? Using the first image for product listing, and other images to slideshow in product detail page. 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