diff --git a/.changeset/wicked-laws-heal.md b/.changeset/wicked-laws-heal.md new file mode 100644 index 000000000..bcaac6132 --- /dev/null +++ b/.changeset/wicked-laws-heal.md @@ -0,0 +1,11 @@ +--- +'@astrojs/image': minor +--- + +HTML attributes included on the `` component are now passed down to the underlying `` element. + +**Why?** + +- when styling a `` the `class` and `style` attributes belong on the `` itself +- `` elements [should not](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture#attributes) actually provide any `aria-` attributes +- `width` and `height` can be added to the `` to help prevent layout shift diff --git a/packages/integrations/image/README.md b/packages/integrations/image/README.md index e57331124..70c6bbcd0 100644 --- a/packages/integrations/image/README.md +++ b/packages/integrations/image/README.md @@ -260,6 +260,10 @@ Position of the crop when fit is `cover` or `contain`. ### `` +The built-in `` component is used to create an optimized `` for both remote images hosted on other domains as well as local images imported from your project's `src` directory. + +In addition to the component-specific properties, any valid HTML attribute for the `` included in the `` component will be included in the built ``. + #### src

diff --git a/packages/integrations/image/components/Picture.astro b/packages/integrations/image/components/Picture.astro index e86ccc65d..7cd71d600 100644 --- a/packages/integrations/image/components/Picture.astro +++ b/packages/integrations/image/components/Picture.astro @@ -65,9 +65,9 @@ delete image.width; delete image.height; --- - + {sources.map((attrs) => )} - +