next.js icon indicating copy to clipboard operation
next.js copied to clipboard

blurDataUrl error when using correct file format

Open AsherWright opened this issue 3 years ago • 2 comments

Verify canary release

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

Provide environment information

I get this error:

Error: Image with src "/dice.png" has "placeholder='blur'" property but is missing the "blurDataURL" property.
          Possible solutions:
            - Add a "blurDataURL" property, the contents should be a small Data URL to represent the image
            - Change the "src" property to a static import with one of the supported file types: jpeg,png,webp,avif
            - Remove the "placeholder" property, effectively no blur effect
          Read more: https://nextjs.org/docs/messages/placeholder-blur-data-url

When I run my dev server, even though the image I'm using is one of the supported file types (png). I may be missing something obvious, but I can't figure it out from the message above.

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

When I run my dev server, I get an error about using the blur prop with Next Image. It tells me that I can't use it unless I'm using a supported file type, but I am using a supported file type.

Expected Behavior

The blur prop should work with a png.

Link to reproduction

https://codesandbox.io/s/gracious-haze-uy1w8p?file=/pages/index.tsx

To Reproduce

Start the dev server and look at the error.

image

AsherWright avatar Nov 01 '22 05:11 AsherWright

Verify canary release

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

Provide environment information

I get this error:

Error: Image with src "/dice.png" has "placeholder='blur'" property but is missing the "blurDataURL" property.
          Possible solutions:
            - Add a "blurDataURL" property, the contents should be a small Data URL to represent the image
            - Change the "src" property to a static import with one of the supported file types: jpeg,png,webp,avif
            - Remove the "placeholder" property, effectively no blur effect
          Read more: https://nextjs.org/docs/messages/placeholder-blur-data-url

When I run my dev server, even though the image I'm using is one of the supported file types (png). I may be missing something obvious, but I can't figure it out from the message above.

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

When I run my dev server, I get an error about using the blur prop with Next Image. It tells me that I can't use it unless I'm using a supported file type, but I am using a supported file type.

Expected Behavior

The blur prop should work with a png.

Link to reproduction

https://codesandbox.io/s/gracious-haze-uy1w8p?file=/pages/index.tsx

To Reproduce

Start the dev server and look at the error.

image

you need to add blurDataURL={"/dice.png"} in next/image component. Just like that: <Image src={"/dice.png"} alt="splash" width="1000" height="500" blurDataURL={"/dice.png"} placeholder="blur" />

imPrathamDev avatar Nov 01 '22 11:11 imPrathamDev

Just import the image:

width & height are not needed in this case

import Image from "next/image";
import dice from '../public/dice.png'

/** Add your relevant code here for the issue to reproduce */
export default function Home() {
  return (
    <div>
      <Image
        src={dice}
        alt="splash"
        placeholder="blur"
      />
    </div>
  );
}

Screenshot 2022-11-01 at 12 48 07

iljamulders avatar Nov 01 '22 11:11 iljamulders

Closing since this is expected behavior. The error message explains it:

Possible solutions:

  • Add a "blurDataURL" property, the contents should be a small Data URL to represent the image
  • Change the "src" property to a static import with one of the supported file types: jpeg,png,webp,avif
  • Remove the "placeholder" property, effectively no blur effect Read more: https://nextjs.org/docs/messages/placeholder-blur-data-url

styfle avatar May 17 '24 20:05 styfle

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

github-actions[bot] avatar Jun 01 '24 12:06 github-actions[bot]