Skip to content

feat(next/image): add support for images.qualities in next.config #74257

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

Merged
merged 13 commits into from
Jan 3, 2025
Prev Previous commit
Next Next commit
add docs
  • Loading branch information
styfle committed Jan 2, 2025
commit aa3bcdca11682e6b8ee367259b7ede300391253c
18 changes: 18 additions & 0 deletions docs/01-app/04-api-reference/02-components/image.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ quality={75} // {number 1-100}

The quality of the optimized image, an integer between `1` and `100`, where `100` is the best quality and therefore largest file size. Defaults to `75`.

If the [`qualities`](#qualities) configuration is defined in `next.config.js`, the `quality` prop must match one of the values defined in the configuration.

> **Good to know**: If the original source image was already low quality, setting the quality prop too high could cause the resulting optimized image to be larger than the original source image.

### `priority`

```js
Expand Down Expand Up @@ -681,6 +685,20 @@ module.exports = {
}
```

### `qualities`

The default [Image Optimization API](#loader) will automatically allow all qualities from 1 to 100. If you wish to restrict the allowed qualities, you can add configuration to `next.config.js`.

```js filename="next.config.js"
module.exports = {
images: {
qualities: [25, 50, 75],
},
}
```

In this example above, only three qualities are allowed: 25, 50, and 75. If the [`quality`](#quality) prop does not match a value in this array, the image will fail with 400 Bad Request.

### `formats`

The default [Image Optimization API](#loader) will automatically detect the browser's supported image formats via the request's `Accept` header in order to determine the best output format.
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy