Skip to content

Commit abad94f

Browse files
fix(gatsby-plugin-sharp): Ensure min 1px height for BLURRED placeholder (#35914)
Co-authored-by: Lennart <[email protected]>
1 parent ae5adb4 commit abad94f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed
Loading

packages/gatsby-plugin-sharp/src/__tests__/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,20 @@ describe(`gatsby-plugin-sharp`, () => {
549549
}
550550
`)
551551
})
552+
553+
it(`handles really wide aspect ratios for blurred placeholder`, async () => {
554+
const result = await base64({
555+
file: getFileObject(
556+
path.join(__dirname, `images/wide-aspect-ratio.png`),
557+
`wide-aspect-ratio`,
558+
`1000x10`
559+
),
560+
args,
561+
})
562+
563+
expect(result.width).toEqual(20)
564+
expect(result.height).toEqual(1)
565+
})
552566
})
553567

554568
describe(`tracedSVG`, () => {

packages/gatsby-plugin-sharp/src/image-data.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,10 @@ export async function generateImageData({
375375
...options,
376376
toFormatBase64: args.blurredOptions?.toFormat,
377377
width: placeholderWidth,
378-
height: Math.round(placeholderWidth / imageSizes.aspectRatio),
378+
height: Math.max(
379+
1,
380+
Math.round(placeholderWidth / imageSizes.aspectRatio)
381+
),
379382
},
380383
reporter,
381384
})

0 commit comments

Comments
 (0)