File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,21 @@ export default function cloudflareLoader({
1313 // Serve the original image when using `next dev`
1414 return src ;
1515 }
16- const params = [ `width=${ width } ` ] ;
17- if ( quality ) {
18- params . push ( `quality=${ quality } ` ) ;
16+
17+ // Sets the requested width by next/image
18+ 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 } ` ) ;
1926 }
20- const paramsString = params . join ( ',' ) ;
21- 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 ) } ` ;
2233}
You can’t perform that action at this time.
0 commit comments