Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add component wrapper in sizes documentation code snippet #39437

Merged
merged 2 commits into from Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions docs/api-reference/next/future/image.md
Expand Up @@ -263,15 +263,17 @@ For example, if you know your styling will cause an image to be full-width on mo

```js
import Image from 'next/image'
;<div className="grid-element">
<Image
src="/example.png"
layout="fill"
sizes="(min-width: 75em) 33vw,
(min-width: 48em) 50vw,
100vw"
/>
</div>
const Example = () => (
<div className="grid-element">
<Image
src="/example.png"
layout="fill"
sizes="(min-width: 75em) 33vw,
(min-width: 48em) 50vw,
100vw"
/>
</div>
)
```

This example `sizes` could have a dramatic effect on performance metrics. Without the `33vw` sizes, the image selected from the server would be 3 times as wide as it needs to be. Because file size is proportional to the square of the width, without `sizes` the user would download an image that's 9 times larger than necessary.
Expand Down
20 changes: 11 additions & 9 deletions docs/api-reference/next/image.md
Expand Up @@ -143,15 +143,17 @@ For example, if you know your styling will cause an image to be full-width on mo

```js
import Image from 'next/image'
;<div className="grid-element">
<Image
src="/example.png"
layout="fill"
sizes="(min-width: 75em) 33vw,
(min-width: 48em) 50vw,
100vw"
/>
</div>
const Example = () => (
<div className="grid-element">
<Image
src="/example.png"
layout="fill"
sizes="(min-width: 75em) 33vw,
(min-width: 48em) 50vw,
100vw"
/>
</div>
)
```

This example `sizes` could have a dramatic effect on performance metrics. Without the `33vw` sizes, the image selected from the server would be 3 times as wide as it needs to be. Because file size is proportional to the square of the width, without `sizes` the user would download an image that's 9 times larger than necessary.
Expand Down