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

Using next/image adds blurwidth and blurheight attributes #56511

Open
1 task done
okonet opened this issue Oct 6, 2023 · 3 comments
Open
1 task done

Using next/image adds blurwidth and blurheight attributes #56511

okonet opened this issue Oct 6, 2023 · 3 comments
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization.

Comments

@okonet
Copy link
Contributor

okonet commented Oct 6, 2023

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/zen-surf-33vcdj?file=%2Fpages%2Findex.tsx%3A2%2C46

To Reproduce

  1. Open code sandbox
  2. Check out the DOM and find the img element.
  3. See how it has unsupported attributes
  4. Check out build console where React is warning about it
CleanShot 2023-10-06 at 10 53 03@2x

Current vs. Expected behavior

There should be no unsupported attributes added to the IMG tag

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Whatever CodeSandbox uses. I'm on Mac M1 but it doesn't matter since it's not related to the environment but React code.

Which area(s) are affected? (Select all that apply)

Image optimization (next/image, next/legacy/image)

Additional context

It's been around since next@12 initial next/image I believe.

@okonet okonet added the bug Issue was opened via the bug report template. label Oct 6, 2023
@github-actions github-actions bot added the Image (next/image) Related to Next.js Image Optimization. label Oct 6, 2023
@Utkarshn10
Copy link

I just saw in code that blurheight and blurwidth are specifically referred in the code. Since they aren't standard HTML attributes then why have they been used here?
image

@joostdecock
Copy link
Contributor

Possibly related, the webpack SVG loader (in NextJS) does add this, no need to use next/image.

This import:

import shoulderslope from './shoulderslope.svg'

Gives me this result

{ 
  src: "/_next/static/media/shoulderslope.a9c4f3f6.svg", 
  height: 1500, 
  width: 2000, 
  blurHeight: 0.
​​  blurWidth: 0
​​}

I got then spread the properties of that import into an <img /> tag:

<img {...importedSvg} />

That gave me the error about blurHeight and blurWidth not being valid, which in turn is how I found this issue.

In my case, the fix was simply to not spread but only use what I needed:

<img src={importedSvg.src} height={importedSvg.heigth} width={importedSvg.width} />

I wanted to share this here to clarify that this can bite you even when not using next/image.

joostdecock added a commit to freesewing/freesewing that referenced this issue Jan 14, 2024
This removes the `blurHeight` and `blurWidth` props from the image tag
in the MeasieImage component.

These were added by the webpack SVG loader, and then spread into the
image.

For background, see: vercel/next.js#56511 (comment)

This closes #5804
joonassandell added a commit to joonassandell/portfolio that referenced this issue May 2, 2024
…lied

- Also remove unnecessary props and add ones that could be needed
- vercel/next.js#56511
joonassandell added a commit to joonassandell/portfolio that referenced this issue May 4, 2024
Among the conversion and linting there are additional changes included:

* Set proper useEffect deps
* Header: Fix initial arrow animation (unnecessary animating happened under the Splash)
* Header: Remove unnecessary animation props that didn't have effect and do minor animation tweaks
* Header: Remove the marquee "transition" key since it isn't a variant
* Header: Rename NavItem -> HeaderNavItem
* Header: Fix useMedia ssr error
* Fix vercel/next.js#65161
* Relocate locomotive-scroll wrapper to components with proper types
* Add build step script for Vercel, not active currently
* Figure: Don't spread props since the invalid blur* attrs could be applied (vercel/next.js#56511)
* Figure: Remove unnecessary props and add ones that could be needed
* Figure: Add alt text to video also
* Tweak tokens
* Slightly tweak some content strings and styles
* Refactor unnecessary stuff away from useInView hook
* Bunch of file extension changes and sort tweaks
* Relocate and fix component script
* Sort keys, jsx props and destructured keys
* Sitemap: Better key for projects
* utility.js -> utils.ts
@pei-tinybird
Copy link

I'm able to reproduce the same problem, using the setup according to the documentation.

image

The imported image has the blurWidth and blurHeight attributes which are not supported by the next/image component.

image

The NextJS versión I'm using is 14.2.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization.
Projects
None yet
Development

No branches or pull requests

4 participants