|
3 | 3 | {% endcomment %} |
4 | 4 |
|
5 | 5 | {% assign image_path = include.path %} |
6 | | -{% assign image_alt = include.alt | default: "" %} |
7 | | -{% assign image_class = include.class | default: "" %} |
| 6 | +{% assign image_alt = include.alt | default: '' %} |
| 7 | +{% assign image_class = include.class | default: '' %} |
8 | 8 |
|
9 | 9 | {% comment %} Extract base path without extension {% endcomment %} |
10 | 10 | {% assign path_parts = image_path | split: '.' %} |
11 | 11 | {% assign extension = path_parts | last %} |
12 | | -{% assign path_without_ext = image_path | replace_last: extension, "" | remove_last: "." %} |
| 12 | +{% assign path_without_ext = image_path | replace_last: extension, '' | remove_last: '.' %} |
13 | 13 |
|
14 | 14 | <picture> |
15 | 15 | {% comment %} WebP sources with different widths {% endcomment %} |
16 | | - <source |
| 16 | + <source |
17 | 17 | type="image/webp" |
18 | | - srcset="{{ path_without_ext }}-480.webp 480w, |
19 | | - {{ path_without_ext }}-800.webp 800w, |
20 | | - {{ path_without_ext }}-1400.webp 1400w" |
21 | | - sizes="(max-width: 480px) 480px, (max-width: 800px) 800px, 1400px"> |
22 | | - |
| 18 | + srcset=" |
| 19 | + {{ path_without_ext }}-480.webp 480w, |
| 20 | + {{ path_without_ext }}-800.webp 800w, |
| 21 | + {{ path_without_ext }}-1400.webp 1400w |
| 22 | + " |
| 23 | + sizes="(max-width: 480px) 480px, (max-width: 800px) 800px, 1400px" |
| 24 | + > |
| 25 | + |
23 | 26 | {% comment %} Fallback to original image {% endcomment %} |
24 | 27 | <img src="{{ image_path }}" alt="{{ image_alt }}" class="{{ image_class }}" loading="lazy"> |
25 | 28 | </picture> |
26 | | - |
|
0 commit comments