[英]How to add Image in section in Shopify?
由於您像這樣調用該部分,所以{% section 'customimg' %}
而不是使用{{ content_for_index }}
所以我假設您希望該部分是靜態的。
首先,您需要在這里閱讀很多有關如何使用章節的信息: https : //help.shopify.com/en/themes/development/sections
本節中的結構必須以這種方式編寫:
{% schema %}
{
"name": "Image",
"settings": [
{
"type": "image_picker",
"id": "image_1",
"label": "Image"
}
]
}
{% endschema %}
img_url: 'master'
不推薦使用img_url: 'master'
不使用它。 改用img_url: '2048x'
。
這是錯誤的{{ settings.image_1 ...
您必須這樣稱呼{{ section.settings.image_1 ...
您無法在該部分之外調用圖片! 您必須在節內調用圖像,因為section
對象只能在節內訪問。
小節/customimg.liquid
{{ section.settings.image_1 | img_url: '2048x' | img_tag }}
{% schema %}
{
"name": "Image",
"settings": [
{
"type": "image_picker",
"id": "image_1",
"label": "Image"
}
]
}
{% endschema %}
templates / index.html
{% section 'customimg' %}
部分/自定義液體
{{ section.settings.image_1 | img_url: '2048x' | img_tag }}
{% schema %}
{
"name": "Image",
"settings": [
{
"type": "image_picker",
"id": "image_1",
"label": "Image"
}
],
"presets": [
{
"name": "Image",
"category": "Content"
}
]
}
{% endschema %}
模板/index.liquid
{{ content_for_index }}
動態方式允許您從管理面板中添加部分而不是單個部分。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.