Thank you so much!
I have a collection.json in templates, and collection–body.liquid, collection–header.liquid
and collection–navigation.liquid in sections. So i guess it’s collection-header.liquid? I’m pasting the code here:
{%- liquid
assign alt_color = section.settings.alt-color
assign apply_overlay = section.settings.apply-overlay
assign enable = section.settings.enable-header
assign image_height = section.settings.image-height
assign show_description = section.settings.show-description
assign show_image = section.settings.show-image
assign show_title = section.settings.show-title
assign title_alignment = section.settings.title-alignment
assign use_image_fallback = section.settings.use-image-fallback
-%}
{% if enable %}
{% capture header_image %}
{% if collection.image %}
{%
render "image",
image: collection.image,
darken: apply_overlay,
darken_mobile: apply_overlay,
full_width: true
%}
{% elsif collection.products.first.featured_media.preview_image and use_image_fallback %}
{%
render "image",
image: collection.products.first.featured_media.preview_image,
darken: apply_overlay,
darken_mobile: apply_overlay,
full_width: true
%}
{% else %}
{% assign show_image = false %}
{% endif %}
{% endcapture %}
{% if show_image %}
{{ header_image }}
{% endif %}
{% if show_title or show_description %}
{% if show_title and collection.title != blank %}
{{ collection.title }}
{% endif %}
{% if show_description and collection.description != blank %}
{{ collection.description }}
{% endif %}
{% endif %}
{% endif %}
{% schema %}
{
“name”: “Collection header”,
“settings”: [
{
“id”: “enable-header”,
“label”: “Enable”,
“type”: “checkbox”,
“default”: true
},
{
“id”: “show-title”,
“label”: “Show collection title”,
“type”: “checkbox”,
“default”: true
},
{
“label”: “Position title”,
“id”: “title-alignment”,
“type”: “radio”,
“options”: [
{ “value”: “left”, “label”: “Left” },
{ “value”: “center”, “label”: “Center” }
],
“default”: “center”
},
{
“id”: “show-description”,
“label”: “Show collection description”,
“type”: “checkbox”,
“default”: true
},
{
“id”: “show-image”,
“label”: “Show collection image”,
“type”: “checkbox”,
“default”: true
},
{
“id”: “use-image-fallback”,
“label”: “Use a product image if no collection image found”,
“type”: “checkbox”,
“default”: true
},
{
“id”: “image-height”,
“label”: “Height”,
“type”: “select”,
“options”: [
{ “value”: “small”, “label”: “Small” },
{ “value”: “medium”, “label”: “Medium” },
{ “value”: “large”, “label”: “Large” },
{ “value”: “original”, “label”: “Natural (no cropping)” }
],
“default”: “medium”
},
{
“id”: “alt-color”,
“label”: “Use light text color”,
“type”: “checkbox”,
“default”: true
},
{
“id”: “apply-overlay”,
“label”: “Darken image”,
“type”: “checkbox”,
“default”: true,
“info”: “Can enhance text visibility”
}
]
}
{% endschema %}