【问题标题】:Need help in getting image source in shopify image_picker在 shopify image_picker 中获取图像源时需要帮助
【发布时间】:2020-05-09 13:20:18
【问题描述】:

这是当前代码:

<img src="{{ block.settings.imageId| img_url: 'large'}}" />

{% schema %}
{
    "name": "Single Mobile Image",
"class": "mobile-index-section",
"max_blocks": 1,
    "blocks": [
        {
            "type": "image_picker",
            "name": "Mobile Image",
        "settings": [
            {
            "type": "image_picker",
            "id": "imageId",
            "label": "Mobile Image"
          }
        ]
    }
],
"presets": [
  {
    "name": "Custom Mobile Image",
    "category": "Image",
    "blocks": [
      {
        "type": "image_picker"
      }
    ]
  }
]
}
{% endschema %}

当使用 {{ block.settings.imageId| img_url: 'large'}} ,我没有得到使用图像选择器在 shopify 自定义中添加的图像。

请帮我找出我做错的地方。

【问题讨论】:

    标签: shopify shopify-template


    【解决方案1】:

    sections.blocks是一个数组元素,需要循环或者定位到特定的索引。

    在你的情况下,{{ section.blocks[0].settings.imageId | img_url: '1024x'}} 会给你第一个块。

    另外不要使用命名大小,它们已被弃用:https://shopify.dev/docs/themes/liquid/reference/filters/deprecated-filters#named-size-parameters

    【讨论】:

      猜你喜欢
      • 2019-12-31
      • 1970-01-01
      • 2011-02-11
      • 1970-01-01
      • 2014-02-23
      • 1970-01-01
      • 2015-08-13
      • 1970-01-01
      • 2013-05-03
      相关资源
      最近更新 更多