Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong message that Image with src "/test.jpg" is smaller than 40x40. Consider removing the "placeholder='blur'" property to improve performance. #26135

Closed
jthcast opened this issue Jun 15, 2021 · 4 comments · Fixed by #26166
Labels
bug Issue was opened via the bug report template.

Comments

@jthcast
Copy link
Contributor

jthcast commented Jun 15, 2021

What version of Next.js are you using?

11

What version of Node.js are you using?

15.12.0

What browser are you using?

Chrome, Safari

What operating system are you using?

macOS

How are you deploying your application?

yarn dev

Describe the Bug

Terminal says Image with src "/test.jpg" is smaller than 40x40. Consider removing the "placeholder='blur'" property to improve performance.

but test.jpg is 14669 × 5000. file is below.
https://commons.wikimedia.org/w/index.php?title=Category:Large_images#/media/File:'Matijevic_Hill'_Panorama_for_Rover's_Ninth_Anniversary_(Stereo).jpg

Expected Behavior

No message with that.

To Reproduce

put that image in public folder and use below code.

<Image
  src='/test.jpg'
  width='fill'
  height='fill'
  layout='responsive'
  placeholder='blur'
  blurDataURL='/test.jpg'
/>
@jthcast jthcast added the bug Issue was opened via the bug report template. label Jun 15, 2021
@jthcast jthcast changed the title Wrong message that Image with placeholder='blur' and blurDataUrl Wrong message that Image with src "/test.jpg" is smaller than 40x40. Consider removing the "placeholder='blur'" property to improve performance. Jun 15, 2021
@ismailToyran
Copy link

ismailToyran commented Jun 15, 2021

Same problem here.
Problem occurs only when I use layout="fill" Without layout fill it works as intended. Even though my image is 400x400 originally, it still shows

"Image with src "..." is smaller than 40x40. Consider removing the "placeholder='blur'" property to improve performance."

To be more specific <Image src={url} width={width} height={height} placeholder="blur" blurDataURL={url} /> works.
<div className="relative w-80 h-80"><Image src={url} placeholder="blur" blurDataURL={url} layout="fill"/></div> not works and throws me the error.

Note: url is external image url which uses contentfull Image Api.
next.config.js setup is

images: {
    domains: ['images.ctfassets.net'],
    deviceSizes: [320, 420, 768, 1024, 1200]
},

@josbroers
Copy link

josbroers commented Jun 15, 2021

Note: url is externalImageApi which is contentfulImageApi.

Having the same problem using imagekit.io and static images, while the images in the _next/static folder are over 800×800.

@jthcast
Copy link
Contributor Author

jthcast commented Jun 15, 2021

This is the point.

<Image
  src='/test.jpg'
  width='fill' // allowed type is string | number
  height='fill' // allowed type is string | number
  layout='responsive'
  placeholder='blur'
  blurDataURL='/test.jpg'
/>

but image.js doing below

function getInt(x) {
    if (typeof x === 'number') {
        return x;
    }
    if (typeof x === 'string') {
        return parseInt(x, 10); // x is now 'fill' string so it will return NaN
    }
    return undefined;
}

const widthInt = getInt(width);
const heightInt = getInt(height);

when width or height are not as string in numeric format , getInt will return NaN.

if ((widthInt || 0) * (heightInt || 0) < 1600) { // cause widthInt and heightInt are NaN then it will 0
  console.warn(`Image with src "${src}" is smaller than 40x40. Consider removing the "placeholder='blur'" property to improve performance.`);
}

so, 0 * 0 < 1600 will true. then message will be print 😅

@kodiakhq kodiakhq bot closed this as completed in #26166 Jun 17, 2021
kodiakhq bot pushed a commit that referenced this issue Jun 17, 2021
## Bug

- [x] Related issues linked using `fixes #26135 `
- [x] Integration tests added

fixes #26135

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #26135 `
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [ ] Make sure the linting passes
flybayer pushed a commit to blitz-js/next.js that referenced this issue Jun 24, 2021
…26166)

## Bug

- [x] Related issues linked using `fixes vercel#26135 `
- [x] Integration tests added

fixes vercel#26135

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes vercel#26135 `
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [ ] Make sure the linting passes
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants