@@ -26,7 +26,7 @@ type ImageProps = Omit<
2626 'src' | 'srcSet' | 'ref' | 'width' | 'height' | 'loading'
2727> & {
2828 src : string
29- quality ?: string
29+ quality ?: number | string
3030 priority ?: boolean
3131 loading ?: LoadingValue
3232 unoptimized ?: boolean
@@ -104,8 +104,8 @@ function getDeviceSizes(width: number | undefined): number[] {
104104function computeSrc (
105105 src : string ,
106106 unoptimized : boolean ,
107- width : number | undefined ,
108- quality ?: string
107+ width ? : number ,
108+ quality ?: number
109109) : string {
110110 if ( unoptimized ) {
111111 return src
@@ -118,7 +118,7 @@ function computeSrc(
118118type CallLoaderProps = {
119119 src : string
120120 width : number
121- quality ?: string
121+ quality ?: number
122122}
123123
124124function callLoader ( loaderProps : CallLoaderProps ) {
@@ -129,8 +129,8 @@ function callLoader(loaderProps: CallLoaderProps) {
129129type SrcSetData = {
130130 src : string
131131 unoptimized : boolean
132- width : number | undefined
133- quality : string | undefined
132+ width ? : number
133+ quality ?: number
134134}
135135
136136function generateSrcSet ( {
@@ -155,7 +155,7 @@ type PreloadData = {
155155 unoptimized : boolean
156156 width : number | undefined
157157 sizes ?: string
158- quality ?: string
158+ quality ?: number
159159}
160160
161161function generatePreload ( {
@@ -251,8 +251,10 @@ export default function Image({
251251 }
252252 } , [ thisEl , lazy ] )
253253
254- let widthInt = getInt ( width )
255- let heightInt = getInt ( height )
254+ const widthInt = getInt ( width )
255+ const heightInt = getInt ( height )
256+ const qualityInt = getInt ( quality )
257+
256258 let divStyle : React . CSSProperties | undefined
257259 let imgStyle : React . CSSProperties | undefined
258260 let wrapperStyle : React . CSSProperties | undefined
@@ -305,12 +307,12 @@ export default function Image({
305307 }
306308
307309 // Generate attribute values
308- const imgSrc = computeSrc ( src , unoptimized , widthInt , quality )
310+ const imgSrc = computeSrc ( src , unoptimized , widthInt , qualityInt )
309311 const imgSrcSet = generateSrcSet ( {
310312 src,
311313 width : widthInt ,
312314 unoptimized,
313- quality,
315+ quality : qualityInt ,
314316 } )
315317
316318 let imgAttributes :
@@ -352,7 +354,7 @@ export default function Image({
352354 width : widthInt ,
353355 unoptimized,
354356 sizes,
355- quality,
357+ quality : qualityInt ,
356358 } )
357359 : '' }
358360 < img
@@ -442,7 +444,5 @@ function defaultLoader({ root, src, width, quality }: LoaderProps): string {
442444 }
443445 }
444446
445- return `${ root } ?url=${ encodeURIComponent ( src ) } &w=${ width } &q=${
446- quality || '100'
447- } `
447+ return `${ root } ?url=${ encodeURIComponent ( src ) } &w=${ width } &q=${ quality || 100 } `
448448}
0 commit comments