File tree 2 files changed +10
-6
lines changed
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([
12
12
`maxHeight` ,
13
13
`quality` ,
14
14
`avifOptions` ,
15
- `jpegOptions ` ,
15
+ `jpgOptions ` ,
16
16
`pngOptions` ,
17
17
`webpOptions` ,
18
18
`blurredOptions` ,
Original file line number Diff line number Diff line change @@ -148,26 +148,30 @@ export async function generateImageData({
148
148
}
149
149
150
150
let primaryFormat : ImageFormat | undefined
151
- let options : Record < string , unknown > | undefined
152
151
if ( useAuto ) {
153
152
primaryFormat = normalizeFormat ( metadata . format || file . extension )
154
153
} else if ( formats . has ( `png` ) ) {
155
154
primaryFormat = `png`
156
- options = args . pngOptions
157
155
} else if ( formats . has ( `jpg` ) ) {
158
156
primaryFormat = `jpg`
159
- options = args . jpgOptions
160
157
} else if ( formats . has ( `webp` ) ) {
161
158
primaryFormat = `webp`
162
- options = args . webpOptions
163
159
} else if ( formats . has ( `avif` ) ) {
164
160
reporter . warn (
165
161
`Image ${ file . relativePath } specified only AVIF format, with no fallback format. This will mean your site cannot be viewed in all browsers.`
166
162
)
167
163
primaryFormat = `avif`
168
- options = args . webpOptions
169
164
}
170
165
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
+
171
175
const imageSizes : {
172
176
sizes : Array < number >
173
177
presentationWidth : number
You can’t perform that action at this time.
0 commit comments