Skip to content

Commit

Permalink
image_tag in video
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerrowsell committed Aug 26, 2022
1 parent 0c561b9 commit 5ac7b97
Showing 1 changed file with 16 additions and 34 deletions.
50 changes: 16 additions & 34 deletions sections/video.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,14 @@
>
<a href="{{ section.settings.video_url }}" class="video-section__poster media media--transparent media--landscape{% if section.settings.cover_image == blank %} video-section__placeholder{% endif %}">
{%- if section.settings.cover_image != blank -%}
<img
srcset="{%- if section.settings.cover_image.width >= 375 -%}{{ section.settings.cover_image | image_url: width: 375 }} 375w,{%- endif -%}
{%- if section.settings.cover_image.width >= 750 -%}{{ section.settings.cover_image | image_url: width: 750 }} 750w,{%- endif -%}
{%- if section.settings.cover_image.width >= 1100 -%}{{ section.settings.cover_image | image_url: width: 1100 }} 1100w,{%- endif -%}
{%- if section.settings.cover_image.width >= 1500 -%}{{ section.settings.cover_image | image_url: width: 1500 }} 1500w,{%- endif -%}
{%- if section.settings.cover_image.width >= 1780 -%}{{ section.settings.cover_image | image_url: width: 1780 }} 1780w,{%- endif -%}
{%- if section.settings.cover_image.width >= 2000 -%}{{ section.settings.cover_image | image_url: width: 2000 }} 2000w,{%- endif -%}
{%- if section.settings.cover_image.width >= 3000 -%}{{ section.settings.cover_image | image_url: width: 3000 }} 3000w,{%- endif -%}
{%- if section.settings.cover_image.width >= 3840 -%}{{ section.settings.cover_image | image_url: width: 3840 }} 3840w,{%- endif -%}
{{ section.settings.cover_image | image_url }} {{ section.settings.cover_image.width }}w"
src="{{ section.settings.cover_image | image_url: width: 1920 }}"
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 %}"
alt="{{ 'sections.video.load_video' | t: description: section.settings.description | escape }}"
loading="lazy"
width="{{ section.settings.cover_image.width }}"
height="{{ section.settings.cover_image.height }}"
>
{% 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 %}
{% assign alt = 'sections.video.load_video' | t: description: section.settings.description | escape %}
{{ section.settings.cover_image | image_url: width: 3840 | image_tag:
loading: 'lazy',
sizes: sizes,
widths: '375, 750, 1100, 1500, 1780, 2000, 3000, 3840',
alt: alt
}}
{%- else -%}
{{ 'collection-2' | placeholder_svg_tag: 'placeholder-svg placeholder' }}
{%- endif -%}
Expand All @@ -63,23 +54,14 @@
aria-label="{{ 'sections.video.load_video' | t: description: section.settings.description | escape }}"
>
{%- if section.settings.cover_image != blank -%}
<img
srcset="{%- if section.settings.cover_image.width >= 375 -%}{{ section.settings.cover_image | image_url: width: 375 }} 375w,{%- endif -%}
{%- if section.settings.cover_image.width >= 750 -%}{{ section.settings.cover_image | image_url: width: 750 }} 750w,{%- endif -%}
{%- if section.settings.cover_image.width >= 1100 -%}{{ section.settings.cover_image | image_url: width: 1100 }} 1100w,{%- endif -%}
{%- if section.settings.cover_image.width >= 1500 -%}{{ section.settings.cover_image | image_url: width: 1500 }} 1500w,{%- endif -%}
{%- if section.settings.cover_image.width >= 1780 -%}{{ section.settings.cover_image | image_url: width: 1780 }} 1780w,{%- endif -%}
{%- if section.settings.cover_image.width >= 2000 -%}{{ section.settings.cover_image | image_url: width: 2000 }} 2000w,{%- endif -%}
{%- if section.settings.cover_image.width >= 3000 -%}{{ section.settings.cover_image | image_url: width: 3000 }} 3000w,{%- endif -%}
{%- if section.settings.cover_image.width >= 3840 -%}{{ section.settings.cover_image | image_url: width: 3840 }} 3840w,{%- endif -%}
{{ section.settings.cover_image | image_url }} {{ section.settings.cover_image.width }}w"
src="{{ section.settings.cover_image | image_url: width: 1920 }}"
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 %}"
alt="{{ 'sections.video.load_video' | t: description: section.settings.description | escape }}"
loading="lazy"
width="{{ section.settings.cover_image.width }}"
height="{{ section.settings.cover_image.height }}"
>
{% 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 %}
{% assign alt = 'sections.video.load_video' | t: description: section.settings.description | escape %}
{{ section.settings.cover_image | image_url: width: 3840 | image_tag:
loading: 'lazy',
sizes: sizes,
widths: '375, 750, 1100, 1500, 1780, 2000, 3000, 3840',
alt: alt
}}
{%- else -%}
{{ 'collection-2' | placeholder_svg_tag: 'placeholder-svg placeholder' }}
{%- endif -%}
Expand Down

0 comments on commit 5ac7b97

Please sign in to comment.