Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Is there a way to have this select the second image in the product images, instead of the first one?
Thank you!
<a href="{{ item.url | within: collections.all }}" class="thumbnail">
<figure class="lazy-image {% if item.image.src contains 'png' %} lazy-image--transparent {% endif %}" data-ratio style="padding-top: 130%">
<img
src="{{ item.image | img_url: '100x130', crop: 'center' }}" alt="{{ item.title | escape }}"
srcset="{{ item.image | img_url: '100x130', crop: 'center' }} 100w, {{ item.image | img_url: '200x260', crop: 'center' }} 260w"
sizes="100px" class="img lazy"
loading="lazy"
width="{{ item.image.width }}" height="{{ item.image.height }}"
/>
</figure>
Solved! Go to the solution
This is an accepted solution.
Hi @kristobar,
Please change all code:
<a href="{{ item.url | within: collections.all }}" class="thumbnail">
{% assign image_product = item.product.media[1] %}
<figure class="lazy-image {% if image_product.src contains 'png' %} lazy-image--transparent {% endif %}" data-ratio style="padding-top: 130%">
<img
src="{{ image_product | img_url: '100x130', crop: 'center' }}" alt="{{ item.title | escape }}"
srcset="{{ image_product | img_url: '100x130', crop: 'center' }} 100w, {{ image_product | img_url: '200x260', crop: 'center' }} 260w"
sizes="100px" class="img lazy"
loading="lazy"
width="{{ image_product.width }}" height="{{ image_product.height }}"
/>
</figure>
Hope it helps!
This is an accepted solution.
Hi @kristobar,
Please change all code:
<a href="{{ item.url | within: collections.all }}" class="thumbnail">
{% assign image_product = item.product.media[1] %}
<figure class="lazy-image {% if image_product.src contains 'png' %} lazy-image--transparent {% endif %}" data-ratio style="padding-top: 130%">
<img
src="{{ image_product | img_url: '100x130', crop: 'center' }}" alt="{{ item.title | escape }}"
srcset="{{ image_product | img_url: '100x130', crop: 'center' }} 100w, {{ image_product | img_url: '200x260', crop: 'center' }} 260w"
sizes="100px" class="img lazy"
loading="lazy"
width="{{ image_product.width }}" height="{{ image_product.height }}"
/>
</figure>
Hope it helps!
Wow thank you!
Would it be possible to add a part that checks if the product has more than one image to select the second one?
Sorry to bug you again
Hi @kristobar,
Please change all code:
<a href="{{ item.url | within: collections.all }}" class="thumbnail">
{% if item.product.media[1] %}
{% assign image_product = item.product.media[1] %}
{% else %}
{% assign image_product = item.image %}
{% endif %}
<figure class="lazy-image {% if image_product.src contains 'png' %} lazy-image--transparent {% endif %}" data-ratio style="padding-top: 130%">
<img
src="{{ image_product | img_url: '100x130', crop: 'center' }}" alt="{{ item.title | escape }}"
srcset="{{ image_product | img_url: '100x130', crop: 'center' }} 100w, {{ image_product | img_url: '200x260', crop: 'center' }} 260w"
sizes="100px" class="img lazy"
loading="lazy"
width="{{ image_product.width }}" height="{{ image_product.height }}"
/>
</figure>
Thank you so much!
Hi @kristobar,
I saw you liked my answer. If it helped you solve your issue, please mark it as a solution. Thank you and good luck.
Hello, is it possible to have that feature just on one "landing page". So in the normal Shop it shows the first image as a thumbnail and on a specific page with featured Products it shows the second image? Maybe over custom css?
Thanks in advance!
Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025