Skip to content

Commit

Permalink
chore: adding a README note for passing attributes to the picture's img
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Sullivan committed Jul 18, 2022
1 parent 5d51da9 commit 5174b6b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/integrations/image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ description: Just a Hello World Post!

For remote images, an `aspectRatio` is required to ensure the correct `height` can be calculated at build time.

Do you need to add attributes to the picture's `<img>` element? Just add them to the `<Picture />`! Any unrecognized props will be added directly to the `<img>` element.

```html
---
import { Picture } from '@astrojs/image';
Expand All @@ -195,6 +197,9 @@ const imageUrl = 'https://www.google.com/images/branding/googlelogo/2x/googlelog

// Inlined imports are supported
<Picture src={import("../assets/hero.png")} widths={[200, 400, 800]} sizes="(max-width: 800px) 100vw, 800px" />

// Add alt and class attributes to the <img>
<Picture src={hero} widths={[200, 400, 800]} sizes="(max-width: 800px) 100vw, 800px" alt="My awesome image" class="my-hero" />
```

</details>
Expand Down

0 comments on commit 5174b6b

Please sign in to comment.