You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add contentDispositionType config to Image Optimization API (#46254)
Add `contentDispositionType` config to Image Optimization API so the user can configure `inline` vs `attachment`.
This is recommended when `dangerouslyAllowSVG` is enabled but can also be used when its disabled.
|`v12.3.0`|`remotePatterns` and `unoptimized` configuration is stable. |
@@ -503,17 +504,20 @@ module.exports = {
503
504
504
505
The default [loader](#loader) does not optimize SVG images for a few reasons. First, SVG is a vector format meaning it can be resized losslessly. Second, SVG has many of the same features as HTML/CSS, which can lead to vulnerabilities without proper [Content Security Policy (CSP) headers](/docs/advanced-features/security-headers.md).
505
506
506
-
If you need to serve SVG images with the default Image Optimization API, you can set `dangerouslyAllowSVG`and `contentSecurityPolicy`inside your `next.config.js`:
507
+
If you need to serve SVG images with the default Image Optimization API, you can set `dangerouslyAllowSVG` inside your `next.config.js`:
In addition, it is strongly recommended to also set `contentDispositionType` to force the browser to download the image, as well as `contentSecurityPolicy` to prevent scripts embedded in the image from executing.
520
+
517
521
### Animated Images
518
522
519
523
The default [loader](#loader) will automatically bypass Image Optimization for animated images and serve the image as-is.
Copy file name to clipboardExpand all lines: docs/api-reference/next/legacy/image.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -571,17 +571,20 @@ module.exports = {
571
571
572
572
The default [loader](#loader) does not optimize SVG images for a few reasons. First, SVG is a vector format meaning it can be resized losslessly. Second, SVG has many of the same features as HTML/CSS, which can lead to vulnerabilities without proper [Content Security Policy (CSP) headers](/docs/advanced-features/security-headers.md).
573
573
574
-
If you need to serve SVG images with the default Image Optimization API, you can set `dangerouslyAllowSVG`and `contentSecurityPolicy`inside your `next.config.js`:
574
+
If you need to serve SVG images with the default Image Optimization API, you can set `dangerouslyAllowSVG` inside your `next.config.js`:
In addition, it is strongly recommended to also set `contentDispositionType` to force the browser to download the image, as well as `contentSecurityPolicy` to prevent scripts embedded in the image from executing.
587
+
585
588
### Animated Images
586
589
587
590
The default [loader](#loader) will automatically bypass Image Optimization for animated images and serve the image as-is.
0 commit comments