Update image shortcode

This commit is contained in:
madrilene 2023-10-30 16:51:00 +01:00
parent 3d10b122ea
commit 95bd4cd960

View file

@ -6,14 +6,14 @@ const imageShortcodePlaceholder = async (
src,
alt,
caption,
sizes = '(min-width: 55rem) 820px, 100vw'
sizes = '(min-width: 55rem) 880px, 100vw'
) => {
if (!alt) {
throw new Error(`Missing \`alt\` on myImage from: ${src}`);
}
let metadata = await Image(src, {
widths: [320, 570, 820],
widths: [320, 570, 880, 1200],
formats: ['avif', 'webp', 'jpeg'],
urlPath: '/assets/images/',
outputDir: './dist/assets/images/',
@ -37,7 +37,7 @@ const imageShortcodePlaceholder = async (
}
return htmlmin.minify(
`<figure>
`<figure class="flow">
<picture>
${Object.values(metadata)
.map(imageFormat => {
@ -55,12 +55,7 @@ const imageShortcodePlaceholder = async (
loading = 'lazy'
decoding="async">
</picture>
${
caption
? `<figcaption class="cluster font-display"><p>${caption}</p>
</figcaption>`
: ``
}
${caption ? `<figcaption>${caption}</figcaption>` : ``}
</figure>`,
{collapseWhitespace: true}
);