Skip to content

Commit 94bbcc2

Browse files
committed
Merge remote-tracking branch 'upstream/canary' into example/i18n
2 parents 29069f1 + 2972c06 commit 94bbcc2

File tree

52 files changed

+876
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+876
-198
lines changed

docs/api-reference/next/image.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: Enable image optimization with the built-in Image component.
2+
description: Enable Image Optimization with the built-in Image component.
33
---
44

55
# next/image
@@ -29,7 +29,12 @@ function Home() {
2929
return (
3030
<>
3131
<h1>My Homepage</h1>
32-
<Image src="/me.png" alt="me" width={200} height={200} />
32+
<Image
33+
src="/me.png"
34+
alt="Picture of the author"
35+
width={500}
36+
height={500}
37+
/>
3338
<p>Welcome to my homepage!</p>
3439
</>
3540
)
@@ -48,6 +53,6 @@ export default Home
4853
- `loading` - The loading behavior. When `lazy`, defer loading the image until it reaches a calculated distance from the viewport. When `eager`, load the image immediately. Default `lazy`. [More info](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-loading)
4954
- `priority` - When true, the image will be considered high priority and [preload](https://web.dev/preload-responsive-images/).
5055
- `unoptimized` - When true, the source image will be served as-is instead of resizing and changing quality.
51-
- `unsized` - When true, the `width` and `height` requirement can by bypassed. Should _not_ be used with `priority` or above-the-fold images.
56+
- `unsized` - When true, the `width` and `height` requirement can by bypassed. Should _not_ be used with above-the-fold images. Should _not_ be used with `priority`.
5257

53-
Another other properties on the `<Image>` component be passed to the underlying `<img>` element.
58+
All other properties on the `<Image>` component will be passed to the underlying `<img>` element.

docs/basic-features/image-optimization.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description: Next.js supports built-in image optimization, as well as third party loaders for Imgix, Cloudinary, and more! Learn more here.
33
---
44

5-
# Image Optimization
5+
# Image Component and Image Optimization
66

77
<details open>
88
<summary><b>Examples</b></summary>
@@ -19,7 +19,7 @@ The Automatic Image Optimization allows for resizing, optimizing, and serving im
1919

2020
## Image Component
2121

22-
To add an image to your application, import the `next/image` component:
22+
To add an image to your application, import the [`next/image`](/docs/api-reference/next/image.md) component:
2323

2424
```jsx
2525
import Image from 'next/image'
@@ -31,8 +31,8 @@ function Home() {
3131
<Image
3232
src="/me.png"
3333
alt="Picture of the author"
34-
width={200}
35-
height={200}
34+
width={500}
35+
height={500}
3636
/>
3737
<p>Welcome to my homepage!</p>
3838
</>
@@ -44,19 +44,32 @@ export default Home
4444

4545
- `width` and `height` are required to prevent [Cumulative Layout Shift](https://web.dev/cls/), a [Core Web Vital](https://web.dev/vitals/) that Google is going to [use in their search ranking](https://webmasters.googleblog.com/2020/05/evaluating-page-experience.html)
4646
- `width` and `height` are automatically responsive, unlike the HTML `<img>` element
47+
- See [`next/image`](/docs/api-reference/next/image.md) for list of available props.
4748

4849
## Configuration
4950

5051
You can configure Image Optimization by using the `images` property in `next.config.js`.
5152

52-
### Sizes
53+
### Device Sizes
5354

54-
You can specify a list of image widths to allow using the `sizes` property. Since images maintain their aspect ratio using the `width` and `height` attributes of the source image, there is no need to specify height in `next.config.js` – only the width. You can think of these as breakpoints.
55+
You can specify a list of device width breakpoints using the `deviceSizes` property. Since images maintain their aspect ratio using the `width` and `height` attributes of the source image, there is no need to specify height in `next.config.js` – only the width. These values will be used by the browser to determine which size image should load.
5556

5657
```js
5758
module.exports = {
5859
images: {
59-
sizes: [320, 420, 768, 1024, 1200],
60+
deviceSizes: [320, 420, 768, 1024, 1200],
61+
},
62+
}
63+
```
64+
65+
### Icon Sizes
66+
67+
You can specify a list of icon image widths using the `iconSizes` property. These widths should be smaller than the smallest value in `deviceSizes`. The purpose is for images that don't scale with the browser window, such as icons or badges. If `iconSizes` is not defined, then `deviceSizes` will be used.
68+
69+
```js
70+
module.exports = {
71+
images: {
72+
iconSizes: [16, 32, 64],
6073
},
6174
}
6275
```
@@ -89,25 +102,19 @@ module.exports = {
89102

90103
The following Image Optimization cloud providers are supported:
91104

92-
- Imgix: `loader: 'imgix'`
93-
- Cloudinary: `loader: 'cloudinary'`
94-
- Akamai: `loader: 'akamai'`
95-
- Vercel: No configuration necessary
105+
- When using `next start` or a custom server image optimization works automatically.
106+
- [Vercel](https://vercel.com): Works automatically when you deploy on Vercel
107+
- [Imgix](https://www.imgix.com): `loader: 'imgix'`
108+
- [Cloudinary](https://cloudinary.com): `loader: 'cloudinary'`
109+
- [Akamai](https://www.akamai.com): `loader: 'akamai'`
96110

97111
## Related
98112

99113
For more information on what to do next, we recommend the following sections:
100114

101115
<div class="card">
102-
<a href="/docs/basic-features/built-in-css-support.md">
103-
<b>CSS Support:</b>
104-
<small>Use the built-in CSS support to add custom styles to your app.</small>
116+
<a href="/docs/api-reference/next/image.md">
117+
<b>next/image</b>
118+
<small>See all available properties for the Image component</small>
105119
</a>
106120
</div>
107-
108-
<div class="card">
109-
- When using `next start` or a custom server image optimization works automatically.
110-
- [Vercel](https://vercel.com): Works automatically when you deploy on Vercel
111-
- [Imgix](https://www.imgix.com): `loader: 'imgix'`
112-
- [Cloudinary](https://cloudinary.com): `loader: 'cloudinary'`
113-
- [Akamai](https://www.akamai.com): `loader: 'akamai'`

docs/manifest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"title": "Built-in CSS Support",
2222
"path": "/docs/basic-features/built-in-css-support.md"
2323
},
24+
{
25+
"title": "Image Optimization",
26+
"path": "/docs/basic-features/image-optimization.md"
27+
},
2428
{
2529
"title": "Fast Refresh",
2630
"path": "/docs/basic-features/fast-refresh.md"
@@ -216,6 +220,10 @@
216220
"title": "next/link",
217221
"path": "/docs/api-reference/next/link.md"
218222
},
223+
{
224+
"title": "next/image",
225+
"path": "/docs/api-reference/next/image.md"
226+
},
219227
{
220228
"title": "next/head",
221229
"path": "/docs/api-reference/next/head.md"

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
"registry": "https://registry.npmjs.org/"
1818
}
1919
},
20-
"version": "9.5.6-canary.13"
20+
"version": "9.5.6-canary.16"
2121
}

packages/create-next-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-next-app",
3-
"version": "9.5.6-canary.13",
3+
"version": "9.5.6-canary.16",
44
"keywords": [
55
"react",
66
"next",

packages/eslint-plugin-next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@next/eslint-plugin-next",
3-
"version": "9.5.6-canary.13",
3+
"version": "9.5.6-canary.16",
44
"description": "ESLint plugin for NextJS.",
55
"main": "lib/index.js",
66
"license": "MIT",

packages/next-bundle-analyzer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@next/bundle-analyzer",
3-
"version": "9.5.6-canary.13",
3+
"version": "9.5.6-canary.16",
44
"main": "index.js",
55
"license": "MIT",
66
"repository": {

packages/next-codemod/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@next/codemod",
3-
"version": "9.5.6-canary.13",
3+
"version": "9.5.6-canary.16",
44
"license": "MIT",
55
"dependencies": {
66
"chalk": "4.1.0",

packages/next-env/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@next/env",
3-
"version": "9.5.6-canary.13",
3+
"version": "9.5.6-canary.16",
44
"keywords": [
55
"react",
66
"next",

packages/next-mdx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@next/mdx",
3-
"version": "9.5.6-canary.13",
3+
"version": "9.5.6-canary.16",
44
"main": "index.js",
55
"license": "MIT",
66
"repository": {

0 commit comments

Comments
 (0)