eleventy-img icon indicating copy to clipboard operation
eleventy-img copied to clipboard

Recipe: Halve the size of images by optimising for high density displays

Open zachleat opened this issue 3 years ago • 1 comments

https://jakearchibald.com/2021/serving-sharp-images-to-high-density-screens/

zachleat avatar Sep 13 '21 15:09 zachleat

I think this may be related to #129, as it could be done by having an option to manually set the img element width attribute. Like this:

async function imageShortcode(src, alt, sizes) {
  const metadata = await Image(src, {
    widths: [300, 600],
  });

  let imageAttributes = {
    alt,
    sizes,
    width: 300,
    loading: "lazy",
    decoding: "async",
  };

  return Image.generateHTML(metadata, imageAttributes);
}

Mantish avatar Jul 08 '22 07:07 Mantish