Created
December 21, 2022 08:42
-
-
Save liamgriffin/c10b6c5a7b09f352e5bece6be536f856 to your computer and use it in GitHub Desktop.
Shopify theme section that displays an externally hosted video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="video-section"> | |
<h2>{{ section.settings.heading }}</h2> | |
{%- if section.settings.video_url.type == 'youtube' -%} | |
<iframe src="https://www.youtube.com/embed/{{ section.settings.video_url.id }}" class="youtube" allow="autoplay; encrypted-media" title="{{ section.settings.description | escape }}"></iframe> | |
{%- else -%} | |
<iframe src="https://player.vimeo.com/video/{{ section.settings.video_url.id }}" class="vimeo" allow="autoplay; encrypted-media" title="{{ section.settings.description | escape }}"></iframe> | |
{%- endif -%} | |
</div> | |
{% schema %} | |
{ | |
"name": "Video", | |
"settings": [ | |
{ | |
"type": "text", | |
"id": "heading", | |
"label": "Video section heading", | |
"default": "Title" | |
}, | |
{ | |
"type": "video_url", | |
"id": "video_url", | |
"accept": [ | |
"youtube", | |
"vimeo" | |
], | |
"default": "https://www.youtube.com/watch?v=_9VUPq3SxOc", | |
"label": "URL", | |
"info": "Video plays in the page." | |
}, | |
{ | |
"type": "text", | |
"id": "description", | |
"label": "Video alt text", | |
"info": "Describe the video for customers using screen readers." | |
} | |
], | |
"presets": [ | |
{ | |
"name": "Video by URL" | |
} | |
] | |
} | |
{% endschema %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment