File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export const SHARP_ATTRIBUTES = new Set([
1212 `maxHeight` ,
1313 `quality` ,
1414 `avifOptions` ,
15- `jpegOptions ` ,
15+ `jpgOptions ` ,
1616 `pngOptions` ,
1717 `webpOptions` ,
1818 `blurredOptions` ,
Original file line number Diff line number Diff line change @@ -148,26 +148,30 @@ export async function generateImageData({
148148 }
149149
150150 let primaryFormat : ImageFormat | undefined
151- let options : Record < string , unknown > | undefined
152151 if ( useAuto ) {
153152 primaryFormat = normalizeFormat ( metadata . format || file . extension )
154153 } else if ( formats . has ( `png` ) ) {
155154 primaryFormat = `png`
156- options = args . pngOptions
157155 } else if ( formats . has ( `jpg` ) ) {
158156 primaryFormat = `jpg`
159- options = args . jpgOptions
160157 } else if ( formats . has ( `webp` ) ) {
161158 primaryFormat = `webp`
162- options = args . webpOptions
163159 } else if ( formats . has ( `avif` ) ) {
164160 reporter . warn (
165161 `Image ${ file . relativePath } specified only AVIF format, with no fallback format. This will mean your site cannot be viewed in all browsers.`
166162 )
167163 primaryFormat = `avif`
168- options = args . webpOptions
169164 }
170165
166+ const optionsMap = {
167+ jpg : args . jpgOptions ,
168+ png : args . pngOptions ,
169+ webp : args . webpOptions ,
170+ avif : args . avifOptions ,
171+ }
172+
173+ const options = primaryFormat ? optionsMap [ primaryFormat ] : undefined
174+
171175 const imageSizes : {
172176 sizes : Array < number >
173177 presentationWidth : number
You can’t perform that action at this time.
0 commit comments