AlluB Posted August 26, 2016 Posted August 26, 2016 Hello, I want to use a image as a cover for a product, the image box that says 'cover' it's ticked but i don't know how to get that image. It makes any sense? This does not work, <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')} Thank you! Share this post Link to post Share on other sites More sharing options...
Gabriel Perez Posted August 26, 2016 Posted August 26, 2016 Try this instead : <img src="{$link->getImageLink($product.link_rewrite, Product::getCover($product.id), 'home_default')}"> Share this post Link to post Share on other sites More sharing options...
AlluB Posted August 26, 2016 Posted August 26, 2016 (edited) Try this instead : <img src="{$link->getImageLink($product.link_rewrite, Product::getCover($product.id), 'home_default')}"> Now the page is blank. I want every product to have it's own cover in the header. I don't know if it's make any sense. Edited August 26, 2016 by AlluB (see edit history) Share this post Link to post Share on other sites More sharing options...
Gabriel Perez Posted August 26, 2016 Posted August 26, 2016 Active the debug to see where is the error. In the header of what page? Can't you use a module for that? Have you seen if the current image is already the cover? (like in product list) Share this post Link to post Share on other sites More sharing options...
AlluB Posted August 26, 2016 Posted August 26, 2016 Active the debug to see where is the error. In the header of what page? Can't you use a module for that? Have you seen if the current image is already the cover? (like in product list) In product.tpl, that's what i'm editing. It doesn't have any cover, i have the header text and above that it should be an image. Share this post Link to post Share on other sites More sharing options...
roja45 Posted August 26, 2016 Posted August 26, 2016 Product::getCover returns as array $images = Product::getCover($id_product);$image_url = $this->context->link->getImageLink($product->link_rewrite, $images['id_image'], ImageType::getFormatedName('home')); 1 1 Share this post Link to post Share on other sites More sharing options...
AlluB Posted August 27, 2016 Posted August 27, 2016 (edited) Product::getCover returns as array $images = Product::getCover($id_product); $image_url = $this->context->link->getImageLink($product->link_rewrite, $images['id_image'], ImageType::getFormatedName('home')); I'm new to Prestashop. Can you please tell me where or how to write this code in product.tpl? Thank you. Edited August 27, 2016 by AlluB (see edit history) Share this post Link to post Share on other sites More sharing options...
roja45 Posted August 27, 2016 Posted August 27, 2016 err, not really, depends on what you're trying to achieve, and your theme, the code above is for use within a module, not a template. If you're trying to get the product image in the header, i.e. you want it near the top, you'll have to use a module, as Gabriel said, or create your own. Share this post Link to post Share on other sites More sharing options...
AlluB Posted August 27, 2016 Posted August 27, 2016 err, not really, depends on what you're trying to achieve, and your theme, the code above is for use within a module, not a template. If you're trying to get the product image in the header, i.e. you want it near the top, you'll have to use a module, as Gabriel said, or create your own. I'm using the Transformer theme. Share this post Link to post Share on other sites More sharing options...
ican Posted July 13, 2019 Posted July 13, 2019 In the PrestaShop 1.7.6, with this solution on category page showing image not available so it's not working on category page. Share this post Link to post Share on other sites More sharing options...
dinesh badrukhiya Posted September 24, 2019 Posted September 24, 2019 Follow this tutorial: How to show cover image of your product with combination in PrestaShop 1.7? 1 Share this post Link to post Share on other sites More sharing options...
Prestapepe Posted March 29, 2021 Posted March 29, 2021 This method does not show homedefault image but a very very big image scalled, I do not recommend this option. Share this post Link to post Share on other sites More sharing options...
Prestapepe Posted March 29, 2021 Posted March 29, 2021 (edited) On 9/24/2019 at 8:23 AM, dinesh badrukhiya said: Follow this tutorial: How to show cover image of your product with combination in PrestaShop 1.7? Use this code instead: {if $product.cover} {assign var='coverImage' value=Product::getCover($product->id)} {assign var='coverImageId' value="{$product->id}-{$coverImage.id_image}"} <a class="thumbnail product-thumbnail" href="{$product.canonical_url}"> <img src="{$link->getImageLink($product.link_rewrite, $coverImageId, 'home_default')}" alt="{if !empty($product.cover.legend)}{$product.cover.legend}{else}{$product.name|truncate:30:'...'}{/if}" data-full-size-image-url="{$product.cover.large.url}" /> </a> {else} <a class="thumbnail product-thumbnail" href="{$product.canonical_url}"> <img src="{$urls.no_picture_image.bySize.home_default.url}" /> </a> {/if} Edited March 29, 2021 by Prestapepe (see edit history) Share this post Link to post 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