From 46ec9101671ee006d126e3946fd8ace33d5c5cb7 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 15 Jun 2021 18:42:29 -0400 Subject: [PATCH 1/2] Update next/image docs and examples --- docs/api-reference/next/image.md | 5 ++++- docs/basic-features/image-optimization.md | 19 +++++++++++++++- examples/image-component/package.json | 6 ++--- examples/image-component/pages/index.js | 22 ++++++++++++++----- examples/image-component/pages/placeholder.js | 13 +++-------- 5 files changed, 44 insertions(+), 21 deletions(-) diff --git a/docs/api-reference/next/image.md b/docs/api-reference/next/image.md index 992ef06ea65e4..88f5b7fe75914 100644 --- a/docs/api-reference/next/image.md +++ b/docs/api-reference/next/image.md @@ -166,7 +166,10 @@ Should only be used when the image is visible above the fold. Defaults to ### placeholder A placeholder to use while the image is loading, possible values are `blur` or `empty`. Defaults to `empty`. -When `placeholder="blur"`, the `blurDataURL` will be used as the placeholder. If the `src` is an object from a static import, then `blurDataURL` will automatically be populated. If the `src` is a string, then you must provide the [`blurDataURL` property](#blurdataurl). + +When `blur`, the [`blurDataURL`](#blurdataurl) property will be used as the placeholder. If `src` is an object from a static import and the imported image is jpg, png, or webp, then `blurDataURL` will automatically be populated. Otherwise you must provide the [`blurDataURL`](#blurdataurl) property. + +When `empty`, there will be no placeholder while the image is loading, only empty space. ## Advanced Props diff --git a/docs/basic-features/image-optimization.md b/docs/basic-features/image-optimization.md index 52a248861c40c..43a65d2790c7b 100644 --- a/docs/basic-features/image-optimization.md +++ b/docs/basic-features/image-optimization.md @@ -31,13 +31,14 @@ To add an image to your application, import the [`next/image`](/docs/api-referen ```jsx import Image from 'next/image' +import profilePic from '../public/me.png' function Home() { return ( <>

My Homepage

Picture of the author (

Placeholder

- Adding placeholder="blur" to an image enables a blurry - placeholder effect while that image loads. + The placeholder property tells the image what to do while + loading.

- - See an example of the blurry placeholder. - + You can optionally enable a blur-up placeholder while the high + resolution image loads.

+

+ Try it out below (you may need to disable cache in dev tools to see the + effect if you already visited): +

+

Internal Image

- The following is an example of a reference to an interal image from the{' '} + The following is an example of a reference to an internal image from the{' '} public directory.

diff --git a/examples/image-component/pages/placeholder.js b/examples/image-component/pages/placeholder.js index 4a0fce5c45c24..fdbab7b7201f2 100644 --- a/examples/image-component/pages/placeholder.js +++ b/examples/image-component/pages/placeholder.js @@ -4,16 +4,9 @@ import mountains from '../public/mountains.jpg' const Responsive = () => (

- -

Image Component With Layout Responsive

- Mountains + +

Image Component With Placeholder

+ Mountains
) From 85102704983fe8299b191a0beaf51c40fc87778b Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 15 Jun 2021 18:58:04 -0400 Subject: [PATCH 2/2] Add width/height back --- examples/image-component/pages/placeholder.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/image-component/pages/placeholder.js b/examples/image-component/pages/placeholder.js index fdbab7b7201f2..2366080b1599c 100644 --- a/examples/image-component/pages/placeholder.js +++ b/examples/image-component/pages/placeholder.js @@ -6,7 +6,13 @@ const Responsive = () => (

Image Component With Placeholder

- Mountains + Mountains
)