使用Minimal Shopify 主题,我建议在collection.liquid中执行以下操作:
<div class="row products">
{% for product in collection.products limit: settings.pagination_limit %}
{% if forloop.index == 4 %}
{% assign image_size = 'large' %}
{% else %}
{% assign image_size = 'small' %}
{% endif %}
{% include 'product-loop' with collection.handle with image_size %}
{% endfor %}
</div>
然后在product-loop.liquid中更改此行:
<img src="{{ product.featured_image | product_img_url: 'large' }}" alt="{{ product.title | escape }}" />
对此:
<img src="{{ product.featured_image | product_img_url: image_size }}" alt="{{ product.title | escape }}" />
一个集合中第 4 个产品的图片会很大,而所有其他产品图片会很小。但是,如果您希望每4 个产品图像都很大,则可以将其放在collection.liquid中:
<div class="row products">
{% for product in collection.products limit: settings.pagination_limit %}
{% capture image_size %}{% cycle 'small', 'small', 'small', 'large' %}{% endcapture %}
{% include 'product-loop' with collection.handle with image_size %}
{% endfor %}
</div>