如何获取简介部分图像 Url?

How to get Intro Section Image Url?

我检查了模板文件中使用的代码: <img {mainImage|image-meta} data-load="false" /> {mainImage|image-meta}

此代码 returns 许多其他属性,例如:

data-src="https://static1.squarespace.com/static/5c12cc27aa49a15fa0c20dbd /t/5c6334730d9297f6e70d6168/1550005372146/iStock-947324428.jpg" data-image="https://static1.squarespace.com/static/5c12cc27aa49a15fa0c20dbd/t/5c6334730d9297f6e70d6168/1550005372146/iStock-947324428.jpg" data-image-dimensions="1600x1068" data-image-focal-point="0.5,0.5" alt="iStock-947324428.jpg"

我想获取图片的唯一src,直接URL,不带任何附加属性

使用 {mainImage.assetUrl} 获得没有附加属性的 src

...|image-meta 被称为 Squarespace imageLoader JSON-T 格式化程序。它有时是一个有用的实用程序,但如果您只需要 src,请使用上述代码。

您可以在 Squarespace's own documentation about this topic.

查看更多关于绕过 ImageLoader 的信息

Bypassing ImageLoader

If you would like to load one of these image sizes explicitly, use the following syntax from within an image context:

<img src="{assetUrl}?format=300w" />

In this case, the image will be the 300w image. Note that this syntax bypasses our imageLoader, and is not recommended for general use. The available image sizes are:

2500w, 1500w, 1000w, 750w, 500w, 300w, 100w