We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9d63850 commit 5134a76Copy full SHA for 5134a76
1 file changed
apps/site/cloudflare/image-loader.ts
@@ -13,10 +13,21 @@ export default function cloudflareLoader({
13
// Serve the original image when using `next dev`
14
return src;
15
}
16
- const params = [`width=${width}`];
17
- if (quality) {
18
- params.push(`quality=${quality}`);
+
+ // Sets the requested width by next/image
+ const params = new Map<string, string>();
19
20
+ if (width > 0) {
21
+ params.set('width', `${width}`);
22
+ }
23
24
+ if (quality && quality > 0) {
25
+ params.set('quality', `${quality}`);
26
- const paramsString = params.join(',');
- return `/cdn-cgi/image/${paramsString}/${normalizeSrc(src)}`;
27
28
+ const pathParams = [...params]
29
+ .map(([key, value]) => `${key}=${value}`)
30
+ .join(',');
31
32
+ return `/cdn-cgi/image/${pathParams}/${normalizeSrc(src)}`;
33
0 commit comments