1
votes

I'm pretty new to Shopify, but I can't seem to reconcile why these two snippets produce the same output (namely, the products always use the featured image, instead of the third image like I want them to)

Before:

{% assign featured_image = false %}
{% if collection.image %}                  
    {% assign featured_image = collection %}                  
    {% assign featured_image_alt = collection.image.alt | escape %}                        
{% elsif collection.products.first.featured_image %}                  
    {% assign featured_image = collection.products.first.featured_image %}   
    {% assign featured_image_alt = collection.title | escape %}                
{% endif %}

After:

{% assign featured_image = collection.products[1].images[2] %}
{% assign featured_image_alt = collection.image.alt | escape %}

Here's where the featured_image gets used

<div class="list-image-wrapper">
  {% if collection.empty? or featured_image == false %}
    {{ 'collection-' | append: current | placeholder_svg_tag: 'placeholder-svg list-image' }}
  {% else %}
    <img
        class="list-image"
        src="{{ featured_image | img_url: '600x600' }}"
        alt="{{ featured_image_alt | escape }}">
  {% endif %}
</div>
1

1 Answers

0
votes

It turns out the file I was editing was the wrong one and isn't used anymore. >.<