Jump to content

Show second image in product categories page instead of default (cover) image


Recommended Posts

How can I show second image on categories page as thumbnails?

product-thumb-tpl has this:

<img
          {if $product.default_image}
            data-full-size-image-url="{$product.default_image.large.url}"
            {generateImagesSources image=$product.default_image size='home_default' lazyload=true}
            alt="{if !empty($product.default_image.legend)}{$product.default_image.legend}{else}{$product.name|truncate:30:'...'}{/if}"
            width="{$product.default_image.bySize.home_default.width}"
            height="{$product.default_image.bySize.home_default.height}"
          {else}
            src="{$urls.no_picture_image.bySize.home_default.url}"
            alt="{$product.name|truncate:30:'...'}"
            width="{$urls.no_picture_image.bySize.home_default.width}"
            height="{$urls.no_picture_image.bySize.home_default.height}"
          {/if}
          class="img-fluid rounded lazyload"
          />

 

But I don't know what should be instead of $product.default_image to show the second image?

Link to comment
Share on other sites

  • 2 weeks later...

If you do the dump on top of the file, you can see it as an array

{dump($product.images)}

 

For example this code may work for you

 

 {if isset($product.images[1])}
 <img src="{$product.images[1].bySize.home_default.url}" />
 {/if}

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...