Unverified Commit 6a65dc5d authored by Steven's avatar Steven Committed by GitHub

Fix `next/future/image` incorrectly warning for `fill` + `blur` (#39986)

This warning was incorrectly printed when `fill` and `placeholder="blur"` were used together:

> Image with src "/test.jpg" is smaller than 40x40. Consider removing the "placeholder='blur'" property to improve performance.
parent c6dafda0
......@@ -697,7 +697,7 @@ export default function Image({
}
if (placeholder === 'blur') {
if ((widthInt || 0) * (heightInt || 0) < 1600) {
if (widthInt && heightInt && widthInt * heightInt < 1600) {
warnOnce(
`Image with src "${src}" is smaller than 40x40. Consider removing the "placeholder='blur'" property to improve performance.`
)
......
import React from 'react'
import Image from 'next/future/image'
import test from '../public/test.jpg'
const Page = () => {
return (
<div>
......@@ -16,6 +18,23 @@ const Page = () => {
>
<Image id="fill-image-1" src="/wide.png" sizes="300px" fill />
</div>
<div
id="image-container-blur"
style={{
height: '300px',
width: '300px',
position: 'relative',
overflow: 'hidden',
}}
>
<Image
id="fill-image-blur"
src={test}
sizes="300px"
placeholder="blur"
fill
/>
</div>
</div>
)
}
......
......@@ -1032,6 +1032,9 @@ function runTests(mode) {
.map((log) => log.message)
.join('\n')
expect(warnings).not.toMatch(/Image with src (.*) has "fill"/gm)
expect(warnings).not.toMatch(
/Image with src (.*) is smaller than 40x40. Consider removing(.*)/gm
)
})
it('should log warnings when using fill mode incorrectly', async () => {
browser = await webdriver(appPort, '/fill-warnings')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment