{% comment %} YouTube Shorts Feed Carousel Section For Shopify - Made By OnHOW Channel - https://www.youtube.com/channel/UCI3_wzBaankhOCSvHlbWSQw {% endcomment %} {%- assign section_id = section.id | replace: '+', '' -%}
{%- if section.settings.anchor_id != blank -%}
{%- endif -%}
{% if section.settings.section_title != blank %}
{% endif %}
{% comment %} Loop through blocks of type 'youtube' {% endcomment %} {% assign youtubes = section.blocks | where: 'type', 'youtube' %} {% for block in youtubes %}
{% assign video_url = block.settings.youtube_video_url %}
{% if video_url != blank %}
{% comment %} Extract YouTube ID {% endcomment %} {% assign yt_id = null %} {% if video_url contains 'shorts/' %} {% assign yt_id = video_url | split: 'shorts/' | last | split: '?' | first %} {% elsif video_url contains 'v=' %} {% assign yt_id = video_url | split: 'v=' | last | split: '&' | first %} {% elsif video_url contains 'youtu.be/' %} {% assign yt_id = video_url | split: 'youtu.be/' | last | split: '?' | first %} {% endif %} {% if yt_id != blank %} {% else %}
{{ block.settings.fallback_text | default: "Watch this Short on YouTube" }}
Open on YouTube
{% endif %}
{% else %}
Please add a YouTube URL
{% endif %}
{% if block.settings.video_caption != blank %}
{{ block.settings.video_caption }}
{% endif %}
{% endfor %}
{% if section.settings.show_arrows %}
{% endif %} {% if section.settings.show_progress %} {% endif %}
{% schema %} { "name": "YouTube Shorts Carousel", "settings": [ { "type": "text", "id": "section_title", "label": "Section Title", "default": "Our YouTube Highlights" }, { "type": "range", "id": "slide_width", "label": "Slide width (px)", "min": 300, "max": 500, "step": 5, "default": 320 }, { "type": "range", "id": "outer_margin", "label": "Outer margin (px)", "default": 0, "min": 0, "max": 100, "step": 5 }, { "type": "range", "id": "inner_padding", "label": "Inner padding (px)", "default": 40, "min": 0, "max": 100, "step": 5 }, { "type": "range", "id": "base_width", "label": "Section base width (%)", "min": 80, "max": 100, "step": 5, "default": 100 }, { "type": "text", "id": "max_width", "label": "Maximum width (e.g. 1200px or 90%)", "default": "1400px" }, { "type": "color_background", "id": "background_color", "label": "Background color", "default": "#ffffff" }, { "type": "range", "id": "border_radius", "label": "Video corner radius", "default": 10, "min": 0, "max": 30, "step": 1 }, { "type": "checkbox", "id": "show_arrows", "label": "Show navigation arrows", "default": true }, { "type": "checkbox", "id": "show_progress", "label": "Show progress bar", "default": true }, { "type": "text", "id": "anchor_id", "label": "Anchor ID", "info": "Use this if you want to link directly to this section, e.g. #my-youtube-section" }, { "type": "color", "id": "border_color", "label": "Arrow color", "default": "#121212" } ], "blocks": [ { "type": "youtube", "name": "YouTube Short", "settings": [ { "type": "url", "id": "youtube_video_url", "label": "YouTube Short URL", "info": "Copy the URL from your browser when viewing the short" }, { "type": "text", "id": "fallback_text", "label": "Fallback Text", "default": "Watch this short on YouTube" }, { "type": "text", "id": "video_caption", "label": "Caption (optional)" }, { "type": "image_picker", "id": "thumbnail_image", "label": "Thumbnail Image", "info": "Used as a fallback if YouTube embed fails" } ] } ], "presets": [ { "name": "YouTube Shorts Carousel", "blocks": [ { "type": "youtube" }, { "type": "youtube" }, { "type": "youtube" }, { "type": "youtube" }, { "type": "youtube" } ] } ] } {% endschema %}