如何在产品页面上获取产品图片网址?

How to fetch product image urls on a product page?

我正在为我的 bigcartel 商店构建自定义主题。尝试实现共享按钮,我想将第一张图片的 URL 插入共享控件。如何只访问第一张图片?谢谢!!

想通了。

您可能想要启动一个指定了 limit 值的 for 循环(见下文)

{% for image in product.images limit:1 %}
  First image URL: {{ image.url }}
{% endfor %}

显然,您可以通过这种方式遍历任何可用数组。

BigCartel documentation

中找到

在产品页面上,或者只要您有可用的 product 变量 - 您可以使用以下方法检索第一张图片:

{{ product.image | product_image_url }}

也记录在此处:

https://developers.bigcartel.com/api/themes#product

product.image   Returns the default image of a product.
product.images  Returns all of the images of a product.
product.image_count Returns the number of images a product has