Skip to content

Commit

Permalink
Remove alt attribute in image_tag filter where unnecessary (Shopify#2117
Browse files Browse the repository at this point in the history
)

* Add fallback to alt attribute where image_tag filter is used

* remove unnecessary use of alt attribute in image_tag filter
  • Loading branch information
ludoboludo authored Nov 21, 2022
1 parent 251e5d9 commit 2f9b9f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
1 change: 0 additions & 1 deletion sections/collage.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<div class="media media--transparent ratio"{% if block.settings.image != blank %} style="--ratio-percent: {{ 1 | divided_by: block.settings.image.aspect_ratio | times: 100 }}%"{% else %} style="--ratio-percent: 100%"{% endif %}>
{%- if block.settings.image != blank -%}
{%- capture sizes -%}(min-width: {{ settings.page_width }}px) {% if section.blocks.size == 1 %}calc({{ settings.page_width }}px - 100px){% else %}{{ settings.page_width | minus: 100 | times: 0.67 | round }}px{% endif %}, (min-width: 750px){% if section.blocks.size == 1 %} calc(100vw - 100px){% else %} 500px{% endif %}, calc(100vw - 30px)}{%- endcapture -%}

{{ block.settings.image | image_url: width: 3000 | image_tag:
loading: 'lazy',
sizes: sizes,
Expand Down
6 changes: 2 additions & 4 deletions sections/image-banner.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
height: image_height,
class: image_class,
sizes: sizes,
widths: '375, 550, 750, 1100, 1500, 1780, 2000, 3000, 3840',
alt: section.settings.image.alt | escape
widths: '375, 550, 750, 1100, 1500, 1780, 2000, 3000, 3840'
}}
</div>
{%- elsif section.settings.image_2 == blank -%}
Expand Down Expand Up @@ -81,8 +80,7 @@
height: image_height_2,
class: image_class_2,
sizes: sizes,
widths: '375, 550, 750, 1100, 1500, 1780, 2000, 3000, 3840',
alt: section.settings.image_2.alt | escape
widths: '375, 550, 750, 1100, 1500, 1780, 2000, 3000, 3840'
}}
</div>
{%- endif -%}
Expand Down
12 changes: 4 additions & 8 deletions snippets/product-thumbnail.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
{{ media.preview_image | image_url: width: 1946 | image_tag:
loading: lazy,
sizes: sizes,
widths: '246, 493, 600, 713, 823, 990, 1100, 1206, 1346, 1426, 1646, 1946',
alt: media.preview_image.alt | escape
widths: '246, 493, 600, 713, 823, 990, 1100, 1206, 1346, 1426, 1646, 1946'
}}
</div>
<a href="{% if media.media_type == 'video' %}{{ media.sources[1].url }}{% else %}{{ media | external_video_url }}{% endif %}" class="product__media-toggle">
Expand All @@ -72,8 +71,7 @@
{{ media.preview_image | image_url: width: 1946 | image_tag:
loading: lazy,
sizes: sizes,
widths: '246, 493, 600, 713, 823, 990, 1100, 1206, 1346, 1426, 1646, 1946',
alt: media.preview_image.alt | escape
widths: '246, 493, 600, 713, 823, 990, 1100, 1206, 1346, 1426, 1646, 1946'
}}
</div>
{%- endif -%}
Expand All @@ -97,8 +95,7 @@
class: image_class,
loading: lazy,
sizes: sizes,
widths: '246, 493, 600, 713, 823, 990, 1100, 1206, 1346, 1426, 1646, 1946',
alt: media.preview_image.alt | escape
widths: '246, 493, 600, 713, 823, 990, 1100, 1206, 1346, 1426, 1646, 1946'
}}
</div>
<button class="product__media-toggle quick-add-hidden product__media-zoom-{{ section.settings.image_zoom }}" type="button" aria-haspopup="dialog" data-media-id="{{ media.id }}">
Expand Down Expand Up @@ -127,8 +124,7 @@
{{ media.preview_image | image_url: width: 1946 | image_tag:
loading: lazy,
sizes: sizes,
widths: '246, 493, 600, 713, 823, 990, 1100, 1206, 1346, 1426, 1646, 1946',
alt: media.preview_image.alt | escape
widths: '246, 493, 600, 713, 823, 990, 1100, 1206, 1346, 1426, 1646, 1946'
}}
</button>
<template>
Expand Down

0 comments on commit 2f9b9f3

Please sign in to comment.