Reputation: 3
Using the below code to show media and don't want to show 2nd image after the featured_image
{% for media in product.media %}
{% case media.media_type %}
{% when 'image' %}
{% unless media == product.images[1] %}
<div class="product-image">
<img src="{{ media | img_url: '100x100'}}" alt="{{ media.alt }}">
</div>
{% endunless %}
{% endcase %}
{% endfor %}
Above code is not working for me. I have tried this "unless media == media.product.images[1]" as well.
Please help....
Upvotes: 0
Views: 892
Reputation: 11
You try to resolve that with "Forloop" and jump in the index of loop when is in the index of de second image!
{% for media in product.media %}
{% case media.media_type %}
{% when 'image' %}
{% if forloop.index == 2 %}
nothing
{% else %}
<div class="product-image">
<img src="{{ media | img_url: '100x100'}}" alt="{{ media.alt }}">
</div>
{% endif %}
{% endcase %}
{% endfor %}
Upvotes: 1