【问题标题】:Call Shopify product image致电 Shopify 产品图片
【发布时间】:2020-03-02 07:16:44
【问题描述】:

我可以使用以下代码调用产品图片的 URL

{{ product | img_url: "medium" }}

这个输出:

//cdn.shopify.com/s/files/1/0087/0462/products/shirt14_medium.jpeg?v=1309278311

当我在这样的<img> 标记中使用此液体代码时

<img src="{{ product | img_url: "medium" }}" />

输出是:

<img src="" />

如何正确显示产品图片?

【问题讨论】:

    标签: shopify liquid shopify-template


    【解决方案1】:

    应该是:

    {{ product.featured_image | img_url: '600x600' | img_tag: product.featured_image.alt }}

    同:

    &lt;img src="{{ product.featured_image | img_url: '600x600' }}" alt="{{product.featured_image.alt}}" /&gt;



    {{ product.images[0]| img_url: '600x600' | img_tag: product.images[0].alt }}

    同:

    &lt;img src="{{ product.images[0] | img_url: '600x600' }}" alt="{{product.images[0].alt}}" /&gt;

    它们都可以工作。

    不要使用已弃用的“中等”,有关详细信息,请参阅此处:https://help.shopify.com/en/themes/liquid/filters/deprecated-filters#named-size-parameters

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多