Unverified Commit bc460229 authored by Steven's avatar Steven Committed by GitHub

Update `next/image` docs for width & height (#35188)

- Fixes #30219 
Co-authored-by: 's avatarRich Haines <hello@richardhaines.dev>
parent 9129bb9a
...@@ -48,15 +48,23 @@ When using an external URL, you must add it to ...@@ -48,15 +48,23 @@ When using an external URL, you must add it to
### width ### width
The width of the image, in pixels. Must be an integer without a unit. The `width` property can represent either the _rendered_ width or _original_ width in pixels, depending on the [`layout`](#layout) and [`sizes`](#sizes) properties.
Required, except for statically imported images, or those with [`layout="fill"`](#layout). When using `layout="intrinsic"`, `layout="fixed"`, or `layout="raw"` without `sizes`, the `width` property represents the _rendered_ width in pixels, so it will affect how large the image appears.
When using `layout="responsive"`, `layout="fill"`, or `layout="raw"` with `sizes`, the `width` property represents the _original_ width in pixels, so it will only affect the aspect ratio.
The `width` property is required, except for [statically imported images](#local-images), or those with `layout="fill"`.
### height ### height
The height of the image, in pixels. Must be an integer without a unit. The `height` property can represent either the _rendered_ height or _original_ height in pixels, depending on the [`layout`](#layout) and [`sizes`](#sizes) properties.
When using `layout="intrinsic"`, `layout="fixed"`, or `layout="raw"` without `sizes`, the `height` property represents the _rendered_ height in pixels, so it will affect how large the image appears.
When using `layout="responsive"`, `layout="fill"`, or `layout="raw"` with `sizes`, the `height` property represents the _original_ height in pixels, so it will only affect the aspect ratio.
Required, except for statically imported images, or those with [`layout="fill"`](#layout). The `height` property is required, except for [statically imported images](#local-images), or those with `layout="fill"`.
## Optional Props ## Optional Props
......
...@@ -150,8 +150,8 @@ One of the ways that images most commonly hurt performance is through _layout sh ...@@ -150,8 +150,8 @@ One of the ways that images most commonly hurt performance is through _layout sh
Because `next/image` is designed to guarantee good performance results, it cannot be used in a way that will contribute to layout shift, and **must** be sized in one of three ways: Because `next/image` is designed to guarantee good performance results, it cannot be used in a way that will contribute to layout shift, and **must** be sized in one of three ways:
1. Automatically, using a [static import](#local-images) 1. Automatically, using a [static import](#local-images)
2. Explicitly, by including a `height` **and** `width` property 2. Explicitly, by including a [`width`](/docs/api-reference/next/image.md#width) and [`height`](/docs/api-reference/next/image.md#height) property
3. Implicitly, by using `layout="fill"` which causes the image to expand to fill its parent element. 3. Implicitly, by using [`layout="fill"`](/docs/api-reference/next/image.md#layout) which causes the image to expand to fill its parent element.
> ### What if I don't know the size of my images? > ### What if I don't know the size of my images?
> >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment