0 like 0 dislike
3 views
asked in Sections Anywhere by (91 points)

1 Answer

0 like 0 dislike
answered by (91 points)

{% for block0 in blocks %}
{% if block_enable[forloop.index0] == blank %}
{% assign my_checkbox0 = false %}
{% else %}
{% assign my_checkbox0 = true %}
{% endif %}
{% assign my_image_key0 = block_image[forloop.index0]| split: '/files/' | last %}
{% assign my_image0 = images[my_image_key0] %}
{% if my_checkbox0 %}
<div>
<div>
<img src="{{ my_image0 | img_url:'master' }}" alt="">
</div>
<span>{{ block_title[forloop.index0] }}</span>
<div>
<p>{{ block_caption[forloop.index0] }}</p>
</div>
</div>
{% endif %}
{% endfor %}

Here's a quick rundown on the image thing:

1. Blocks is an array so we loop through them

{% for block0 in blocks %}

2. block_image[forloop.index0] is just a string - the name of the image file. In order to use the img_url filter, we turn it into an object by pulling it out of the Shopify global images object

{% assign my_image_key0 = block_image[forloop.index0]| split: '/files/' | last %}
{% assign my_image0 = images[my_image_key0] %}

3. We use our new image object with the img_url filter to output the correct size

<img src="{{ my_image0 | img_url:'master' }}" alt="">

Ask questions and receive answers from our expert developers and other members of the community.
...