Skip to content

Commit 1d84127

Browse files
committed
chore: update readme
1 parent b45f35b commit 1d84127

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

README.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ The package helps you use the Uploadcare's transformation and CDN services from
1212

1313
It provides the `uploadcareLoader` function, which you can use as [a custom loader for the Next's Image component](https://nextjs.org/docs/api-reference/next/image#loader), and the `UploadcareImage` component with the custom loader enabled by default.
1414

15-
1615
* [Demo](#demo)
1716
* [Dependencies](#dependencies)
1817
* [Installation](#installation)
1918
* [Configuration](#configuration)
2019
* [Usage](#usage)
20+
* [Props](#props)
2121
* [Notes](#notes)
2222
* [Known Issues](#known-issues)
2323
* [Links](#links)
@@ -28,7 +28,7 @@ Look at the demo [here][demo-link].
2828

2929
## Dependencies
3030

31-
The only dependency is Next.js >= 10.0.5.
31+
The only dependency is Next.js >= 10.0.5.
3232

3333
## Installation
3434

@@ -108,7 +108,7 @@ The `UploadcareImage` component supports the same parameters as the Next `Image`
108108
import Image from 'next/image';
109109
import { uploadcareLoader } from '@uploadcare/nextjs-loader';
110110

111-
<Image
111+
<Image
112112
alt="A test image"
113113
src="https://your-domain/image.jpg"
114114
width="400"
@@ -122,7 +122,7 @@ import { uploadcareLoader } from '@uploadcare/nextjs-loader';
122122

123123
In that case, you may not need the `loader: "custom"` setting in your `next.config.js`.
124124

125-
1. Install [next-image-loader](https://www.npmjs.com/package/next-image-loader) and enable it as described in its README.
125+
1. Install [next-image-loader](https://www.npmjs.com/package/next-image-loader) and enable it as described in its README.
126126

127127
2. Create `image-loader.config.js` in the project root (in the same directory as `next.config.js`)
128128
and add this code to it:
@@ -140,7 +140,7 @@ imageLoader.loader = uploadcareLoader;
140140
```tsx
141141
import Image from 'next/image';
142142

143-
<Image
143+
<Image
144144
alt="A test image"
145145
src="https://your-domain/image.jpg"
146146
width="400"
@@ -155,7 +155,7 @@ Please note that you can still use any other loader for a separate image like th
155155
import Image from 'next/image';
156156
import anotherLoader from '[another-loader-project-name]';
157157

158-
<Image
158+
<Image
159159
alt="A test image"
160160
src="https://your-domain/image.jpg"
161161
width="400"
@@ -167,15 +167,46 @@ import anotherLoader from '[another-loader-project-name]';
167167

168168
where `anotherLoader` will be used instead of the Uploadcare loader for this particular image.
169169

170+
## Props
171+
172+
### `placeholder` and `blurDataURL`
173+
174+
This options is available for the `UploadcareImage` component only. It won't work when you're using custom loader derectly.
175+
176+
If you pass `placeholder="blur"` to the `UploadcareImage` component, it will generate `blurDataURL` with the URL of the placeholder image (not base64) and use it as a placeholder. You can override `blurDataURL`.
177+
178+
[Read more](https://nextjs.org/docs/api-reference/next/image#placeholder) about `placeholder` and `blurDataURL`.
179+
180+
```tsx
181+
182+
```jsx
183+
<UploadcareImage
184+
alt="A test image"
185+
src="https://your-domain/image.jpg"
186+
width="400"
187+
height="300"
188+
quality="80"
189+
placeholder="blur"
190+
/>
191+
```
192+
170193
## Notes
171194

172195
- If you have jpegs larger than 3000px and you want loader to resize them up to 5000px, you need to pass filename with `jpeg` or `jpg` extension to the src url. See [Output image dimensions docs](https://uploadcare.com/docs/transformations/image/#dimensions) for more details. When no filename provided, we'll treat the image as non-jpeg and can resize it up to 3000px only.
173196

174197
- If you pass a local image url, the loader returns it AS IS if the app is run in the development mode or if the `NEXT_PUBLIC_UPLOADCARE_APP_BASE_URL` is not set.
175198

199+
- Next.js Image component allows numeric only `quality` value. Uploadcare CDN supports string-based quality only (see [our docs](https://uploadcare.com/docs/transformations/image/compression/#operation-quality)). So numeric quality values will be mapped onto string ones using the following intervals:
200+
201+
- 1-38 - lightest
202+
- 39-70 - lighter
203+
- 71-80 - normal
204+
- 81-88 - better
205+
- 89-100 - best
206+
176207
## Known Issues
177208

178-
**Issue 1:** Console warning like this:
209+
**Issue 1:** Console warning like this:
179210
> Image with src "${src}" has a "loader" property that does not implement width. Please implement it or use the "unoptimized" property instead.
180211
Read more: https://nextjs.org/docs/messages/next-image-missing-loader-width
181212

0 commit comments

Comments
 (0)