Skip to content

Commit 9f7f4aa

Browse files
committed
Revert "Redo responsive img w/ new knowledge"
This reverts commit 6f74ab3.
1 parent 6f74ab3 commit 9f7f4aa

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

_includes/shortcodes/responsive-image.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ module.exports = async (src, alt, outputFormat = 'jpeg') => {
1414
});
1515

1616
const lowestSrc = stats[outputFormat][0];
17-
const srcset = Object.values(stats).map((imageFormat) => `${imageFormat.map((entry) => `${entry.url} ${entry.width}w`).join(', ')}`).join('\n');
17+
const sizes = '(max-width: 400px) 400px, (max-width: 800px) 800px, 100vw';
18+
const sourceBlock = Object.values(stats).map((imageFormat) => `<source type="image/${imageFormat[0].format}" srcset="${imageFormat.map((entry) => `${entry.url} ${entry.width}w`).join(', ')}" sizes="${sizes}">`).join('\n');
1819

19-
return `<img src="${lowestSrc.url}" srcset="${srcset}" width="${lowestSrc.width}" height="${lowestSrc.height}" alt="${alt}" loading="lazy">`;
20+
return `<picture class="image">
21+
${sourceBlock}
22+
<img src="${lowestSrc.url}" width="${lowestSrc.width}" height="${lowestSrc.height}" alt="${alt}" loading="lazy">`;
2023
} catch (err) {
2124
// eslint-disable-next-line no-console
2225
console.error('Responsive Image: eleventy-img error:', err);

_layouts/base.liquid

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@
5959
</div>
6060

6161
{%- if page.url == '/' -%}
62-
<figure class="image">
63-
{% responsiveImage "./assets/img/carlos-alfonso-AlBgcDfDG_s-unsplash_min.jpg", "Austin Skyline by Carlos Alfonso on Unsplash" %}
64-
</figure>
62+
{% responsiveImage "./assets/img/carlos-alfonso-AlBgcDfDG_s-unsplash_min.jpg", "Austin Skyline by Carlos Alfonso on Unsplash" %}
6563
{%- endif -%}
6664
</header>
6765

0 commit comments

Comments
 (0)