AlluB Posted August 26, 2016 Share 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! Link to comment Share on other sites More sharing options...
Gabriel Perez Posted August 26, 2016 Share Posted August 26, 2016 Try this instead : <img src="{$link->getImageLink($product.link_rewrite, Product::getCover($product.id), 'home_default')}"> Link to comment Share on other sites More sharing options...
AlluB Posted August 26, 2016 Author Share 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) Link to comment Share on other sites More sharing options...
Gabriel Perez Posted August 26, 2016 Share 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) Link to comment Share on other sites More sharing options...
AlluB Posted August 26, 2016 Author Share 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. Link to comment Share on other sites More sharing options...
roja45 Posted August 26, 2016 Share 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 Link to comment Share on other sites More sharing options...
AlluB Posted August 27, 2016 Author Share 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) Link to comment Share on other sites More sharing options...
roja45 Posted August 27, 2016 Share 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. Link to comment Share on other sites More sharing options...
AlluB Posted August 27, 2016 Author Share 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. Link to comment Share on other sites More sharing options...
ican Posted July 13, 2019 Share 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. Link to comment Share on other sites More sharing options...
dinesh badrukhiya Posted September 24, 2019 Share Posted September 24, 2019 Follow this tutorial: How to show cover image of your product with combination in PrestaShop 1.7? 1 Link to comment Share on other sites More sharing options...
Prestapepe Posted March 29, 2021 Share Posted March 29, 2021 This method does not show homedefault image but a very very big image scalled, I do not recommend this option. Link to comment Share on other sites More sharing options...
Prestapepe Posted March 29, 2021 Share 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) 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