diff --git a/.changeset/selfish-files-smoke.md b/.changeset/selfish-files-smoke.md new file mode 100644 index 000000000..0db99d355 --- /dev/null +++ b/.changeset/selfish-files-smoke.md @@ -0,0 +1,5 @@ +--- +'@astrojs/image': patch +--- + +Do not pass width and height to the img element when wrapped in a picture element diff --git a/packages/integrations/image/components/Picture.astro b/packages/integrations/image/components/Picture.astro index a2d80354a..e86ccc65d 100644 --- a/packages/integrations/image/components/Picture.astro +++ b/packages/integrations/image/components/Picture.astro @@ -60,6 +60,9 @@ const { image, sources } = await getPicture({ background, position, }); + +delete image.width; +delete image.height; --- diff --git a/packages/integrations/image/test/picture-ssg.test.js b/packages/integrations/image/test/picture-ssg.test.js index d68d43782..a997b57f1 100644 --- a/packages/integrations/image/test/picture-ssg.test.js +++ b/packages/integrations/image/test/picture-ssg.test.js @@ -235,8 +235,6 @@ describe('SSG pictures - build', function () { const image = $(`${id} img`); expect(image.attr('src')).to.match(regex); - expect(image.attr('width')).to.equal(size.width.toString()); - expect(image.attr('height')).to.equal(size.height.toString()); expect(image.attr('alt')).to.equal(alt); verifyImage(image.attr('src'), size); @@ -330,8 +328,6 @@ describe('SSG pictures with subpath - build', function () { const image = $(`${id} img`); expect(image.attr('src')).to.match(regex); - expect(image.attr('width')).to.equal(size.width.toString()); - expect(image.attr('height')).to.equal(size.height.toString()); expect(image.attr('alt')).to.equal(alt); verifyImage(image.attr('src').replace('/docs', ''), size);