【问题标题】:Can't add shopify image through url无法通过 url 添加shopify图片
【发布时间】:2022-06-14 04:05:33
【问题描述】:

我在处理此代码时遇到了问题:

<!doctype html>
<html>
<head>
<title>{{ page_title }}</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="{{ page_description | escape }}">
<link rel="canonical" href="{{ canonical_url }}">
<link rel="stylesheet" href="{{ 'some.css' | asset_url }}" type="text/css">

<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
{{ content_for_header }} <!-- Header hook for plugins -->
{{ 'bootstrap.min.css' | asset_url | stylesheet_tag }}

</head>
<body>
{% section 'header'%}
<img src="{{section.settings.image | img_url}}" alt="">
<main role="main">
{{ content_for_layout }}
</main>
{{ 'bootstrap.min.js' | asset_url | script_tag }}
{{'https://cdn.shopify.com/s/files/1/0585/4674/9577/files/Untitled-1.jpg?v=1655109717' | 
img_url: '150x'| image_tag'}}

</body>
</html>

图片的错误是这样的:

液体错误:image_tag 的输入必须是 image_url

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    正如documentation 中所写,在您的错误中,您需要提供具有宽度或高度的image_url 过滤器才能使用image_tag HTML 过滤器。 此外,过滤器img_url 已弃用。

    我假设此图像存储在 Shopify 商店的文件中,因此最好使用带有 file_img_url 过滤器的 img 标签。

    <img src="{{ 'Untitled-1.jpg' | file_img_url: '150x' }}" alt="Image">
    

    【讨论】:

      猜你喜欢
      • 2012-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多