【问题标题】:Shopify Flow - Image FiltersShopify Flow - 图像过滤器
【发布时间】:2022-10-16 15:19:02
【问题描述】:

我正在尝试设置一个在有特殊订单时发送内部电子邮件的流程 - 由 Shopify Flow 触发。

除图像 URL 外,一切正常。

传统上,在 Liquid + HTML 中,您可以编写:

{{ product| img_url: '200x200' }}
{{ product.image | img_url: '200x200' }}
{{ product.featuredImage | img_url: '200x200' }}
{{ product | image_url: width: 200, height: 200 }} 

我正在尝试在 Shopify Flow 中做同样的事情,但它都不起作用,并且文档中没有关于图像的任何内容。

他们确实指定:

“如果未指定任何变换选项,则将保留原始图像,包括任何预先应用的变换。”

我找到了这方面的文档......但仅限于GraphQL。 Shopify Flow 上的示例为零。

现在,这就是我所拥有的,但它正在以全尺寸渲染图像。我可以用 CSS 调整它的大小,但是这些会很快占用我的电子邮件存储空间:

{% for item in order.lineItems %}
  <img src="{{ item.image.url }}" /> // <--------- HERE
{{ item.title}} - {{ item.sku }} - {{ item.quantity }}
{% endfor %}

这些是我得到的错误代码:

Liquid error: undefined filter img_url
Liquid error: undefined filter product_img_url
Liquid error: undefined filter img_tag
Liquid error: undefined filter img_tag_url

谢谢!

【问题讨论】:

  • 您可以尝试使用 src 而不是 URL 吗?
  • 如果不支持这些过滤器,您可能需要自己构建 URL。

标签: shopify liquid


【解决方案1】:

感谢保罗的cmets。

我添加了字符串过滤器来构建 url:

{{ item.image.url | replace: '.png', '_100x100.png' | replace: '.jpg', '_x100x100.jpg'}}

这适用于电子邮件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-09
    • 2012-01-02
    • 1970-01-01
    • 1970-01-01
    • 2015-11-11
    • 2011-10-13
    • 2015-12-10
    相关资源
    最近更新 更多