Video Code effecting Dawn theme

Topic summary

A user modified the Video liquid file in their Dawn theme to enable homepage video autoplay, muting, and remove the play icon. However, this code is causing unintended issues on another page containing a different video.

Problems identified:

  • The affected page loads from the bottom instead of top
  • Text at the top of the page fails to display properly

Solution provided:
Another user suggested wrapping the custom JavaScript code with a template conditional to restrict it to the homepage only:

{% if template == 'index' %}
[custom autoplay code here]
{% endif %}

This approach ensures the autoplay functionality only applies to the homepage video, preventing conflicts on other pages. The original poster confirmed the solution worked by thanking the respondent.

Status: Resolved

Summarized with AI on November 5. AI used: claude-sonnet-4-5-20250929.

Hello,

I have added some code to the Video liquid file so that homepage video auto plays, is muted and removes the play icon (https://www.newyearsevelondon.co.uk/)

However, this has effected a different page on the site which also has a different video (https://www.newyearsevelondon.co.uk/pages/new-years-eve-masquerade-ball-2024-after-party).

The page loads from the bottom and there is an issue with the text at the top of the page not showing.

Does anyone have a solution please?

Here is the code for the Video liquid file:

{{ ‘video-section.css’ | asset_url | stylesheet_tag }}
{{ ‘component-deferred-media.css’ | asset_url | stylesheet_tag }}

{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}

@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}

{%- liquid
assign video_id = section.settings.video.id | default: section.settings.video_url.id
assign video_alt = section.settings.video.alt | default: section.settings.description
assign alt = ‘sections.video.load_video’ | t: description: video_alt | escape
assign poster = section.settings.video.preview_image | default: section.settings.cover_image

if section.settings.video != null
assign ratio_diff = section.settings.video.aspect_ratio | minus: poster.aspect_ratio | abs
if ratio_diff < 0.01 and ratio_diff > 0
assign fix_ratio = true
endif
endif
-%}

{%- capture sizes -%}
{% if section.settings.full_width -%}
100vw
{%- else -%}
(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 }}px, (min-width: 750px)
calc(100vw - 10rem), 100vw
{%- endif %}
{%- endcapture -%}

{%- unless section.settings.heading == blank -%}

{{ section.settings.heading }}

{%- endunless -%}
{%- if poster != null -%} {{ poster | image_url: width: 3840 | image_tag: sizes: sizes, widths: '375, 750, 1100, 1500, 1780, 2000, 3000, 3840', alt: alt }} {%- else -%} {{ 'hero-apparel-3' | placeholder_svg_tag: 'placeholder-svg placeholder' }} {%- endif -%} {%- render 'icon-play' -%} {%- if section.settings.video == null and section.settings.video_url != null -%} {%- liquid assign loop = '' if section.settings.enable_video_looping assign loop = '&loop=1&playlist=' | append: video_id endif -%} {%- if section.settings.video_url.type == 'youtube' -%} {%- else -%} {%- endif -%} {%- else -%} {{ section.settings.video | video_tag: image_size: '1100x', autoplay: true, loop: section.settings.enable_video_looping, controls: true, muted: true }} {%- endif -%}

{% schema %}
{
“name”: “t:sections.video.name”,
“tag”: “section”,
“class”: “section”,
“disabled_on”: {
“groups”: [“header”, “footer”]
},
“settings”: [
{
“type”: “inline_richtext”,
“id”: “heading”,
“default”: “t:sections.video.settings.heading.default”,
“label”: “t:sections.video.settings.heading.label”
},
{
“type”: “select”,
“id”: “heading_size”,
“options”: [
{
“value”: “h2”,
“label”: “t:sections.all.heading_size.options__1.label”
},
{
“value”: “h1”,
“label”: “t:sections.all.heading_size.options__2.label”
},
{
“value”: “h0”,
“label”: “t:sections.all.heading_size.options__3.label”
},
{
“value”: “hxl”,
“label”: “t:sections.all.heading_size.options__4.label”
},
{
“value”: “hxxl”,
“label”: “t:sections.all.heading_size.options__5.label”
}
],
“default”: “h1”,
“label”: “t:sections.all.heading_size.label”
},
{
“type”: “checkbox”,
“id”: “enable_video_looping”,
“label”: “t:sections.video.settings.enable_video_looping.label”,
“default”: false
},
{
“type”: “header”,
“content”: “t:sections.video.settings.header__1.content”
},
{
“type”: “video”,
“id”: “video”,
“label”: “t:sections.video.settings.video.label”
},
{
“type”: “header”,
“content”: “t:sections.video.settings.header__2.content”
},
{
“type”: “paragraph”,
“content”: “t:sections.video.settings.paragraph.content”
},
{
“type”: “video_url”,
“id”: “video_url”,
“accept”: [“youtube”, “vimeo”],
“default”: “https://www.youtube.com/watch?v=_9VUPq3SxOc”,
“label”: “t:sections.video.settings.video_url.label”,
“info”: “t:sections.video.settings.video_url.info”
},
{
“type”: “image_picker”,
“id”: “cover_image”,
“label”: “t:sections.video.settings.cover_image.label”
},
{
“type”: “text”,
“id”: “description”,
“label”: “t:sections.video.settings.description.label”,
“info”: “t:sections.video.settings.description.info”
},
{
“type”: “header”,
“content”: “t:sections.video.settings.header__3.content”
},
{
“type”: “checkbox”,
“id”: “full_width”,
“label”: “t:sections.video.settings.full_width.label”,
“default”: false
},
{
“type”: “color_scheme”,
“id”: “color_scheme”,
“label”: “t:sections.all.colors.label”,
“default”: “scheme-1”
},
{
“type”: “header”,
“content”: “t:sections.all.padding.section_padding_heading”
},
{
“type”: “range”,
“id”: “padding_top”,
“min”: 0,
“max”: 100,
“step”: 4,
“unit”: “px”,
“label”: “t:sections.all.padding.padding_top”,
“default”: 36
},
{
“type”: “range”,
“id”: “padding_bottom”,
“min”: 0,
“max”: 100,
“step”: 4,
“unit”: “px”,
“label”: “t:sections.all.padding.padding_bottom”,
“default”: 36
}
],
“presets”: [
{
“name”: “t:sections.video.presets.name”
}
]
}
{% endschema %}

Thanks

Christina

1 Like

hello @ofhaides

Replace the section file and add a new code after checking both pages.

{% if template == 'index' %}

{% endif %}

{{ 'video-section.css' | asset_url | stylesheet_tag }}
{{ 'component-deferred-media.css' | asset_url | stylesheet_tag }}

{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}

@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}

{%- liquid
assign video_id = section.settings.video.id | default: section.settings.video_url.id
assign video_alt = section.settings.video.alt | default: section.settings.description
assign alt = 'sections.video.load_video' | t: description: video_alt | escape
assign poster = section.settings.video.preview_image | default: section.settings.cover_image

if section.settings.video != null
assign ratio_diff = section.settings.video.aspect_ratio | minus: poster.aspect_ratio | abs
if ratio_diff < 0.01 and ratio_diff > 0
assign fix_ratio = true
endif
endif
-%}

{%- capture sizes -%}
{% if section.settings.full_width -%}
100vw
{%- else -%}
(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 }}px, (min-width: 750px)
calc(100vw - 10rem), 100vw
{%- endif %}
{%- endcapture -%}

{%- unless section.settings.heading == blank -%}

## {{ section.settings.heading }}

{%- endunless -%}

{% schema %}
{
"name": "t:sections.video.name",
"tag": "section",
"class": "section",
"disabled_on": {
"groups": ["header", "footer"]
},
"settings": [
{
"type": "inline_richtext",
"id": "heading",
"default": "t:sections.video.settings.heading.default",
"label": "t:sections.video.settings.heading.label"
},
{
"type": "select",
"id": "heading_size",
"options": [
{
"value": "h2",
"label": "t:sections.all.heading_size.options__1.label"
},
{
"value": "h1",
"label": "t:sections.all.heading_size.options__2.label"
},
{
"value": "h0",
"label": "t:sections.all.heading_size.options__3.label"
},
{
"value": "hxl",
"label": "t:sections.all.heading_size.options__4.label"
},
{
"value": "hxxl",
"label": "t:sections.all.heading_size.options__5.label"
}
],
"default": "h1",
"label": "t:sections.all.heading_size.label"
},
{
"type": "checkbox",
"id": "enable_video_looping",
"label": "t:sections.video.settings.enable_video_looping.label",
"default": false
},
{
"type": "header",
"content": "t:sections.video.settings.header__1.content"
},
{
"type": "video",
"id": "video",
"label": "t:sections.video.settings.video.label"
},
{
"type": "header",
"content": "t:sections.video.settings.header__2.content"
},
{
"type": "paragraph",
"content": "t:sections.video.settings.paragraph.content"
},
{
"type": "video_url",
"id": "video_url",
"accept": ["youtube", "vimeo"],
"default": "https://www.youtube.com/watch?v=_9VUPq3SxOc",
"label": "t:sections.video.settings.video_url.label",
"info": "t:sections.video.settings.video_url.info"
},
{
"type": "image_picker",
"id": "cover_image",
"label": "t:sections.video.settings.cover_image.label"
},
{
"type": "text",
"id": "description",
"label": "t:sections.video.settings.description.label",
"info": "t:sections.video.settings.description.info"
},
{
"type": "header",
"content": "t:sections.video.settings.header__3.content"
},
{
"type": "checkbox",
"id": "full_width",
"label": "t:sections.video.settings.full_width.label",
"default": false
},
{
"type": "color_scheme",
"id": "color_scheme",
"label": "t:sections.all.colors.label",
"default": "scheme-1"
},
{
"type": "header",
"content": "t:sections.all.padding.section_padding_heading"
},
{
"type": "range",
"id": "padding_top",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_top",
"default": 36
},
{
"type": "range",
"id": "padding_bottom",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_bottom",
"default": 36
}
],
"presets": [
{
"name": "t:sections.video.presets.name"
}
]
}
{% endschema %}

Best Regards,
Dws_pvt_ltd

1 Like

Thank you!