可以通过URL添加Shopify图像

发布于 2025-02-06 18:25:36 字数 1082 浏览 1 评论 0原文

我在此代码上遇到麻烦:

<!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

I am having trouble regarding this code:

<!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>

The error for image is this:

Liquid error: input to image_tag must be an image_url

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝礼 2025-02-13 18:25:36

文档 image_url具有宽度或高度的过滤器,以便使用image_tag html过滤器。
另外,ever 被弃用。

我假设此图像存储在Shopify商店的文件中,因此最好使用img使用file> file_img_url filter。

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

As written in the documentation and in your error you need to provide an image_url filter with width or height in order to use the image_tag HTML filter.
Also, the filter img_url is deprecated.

I assume that this image is stored in the Files of the Shopify store, so it would be best to use an img tag with a file_img_url filter.

<img src="{{ 'Untitled-1.jpg' | file_img_url: '150x' }}" alt="Image">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文