Skip to content

Docs: The Getting Started docs about local images using the <Image> component are wrong #80023

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

Closed
ChristianIvicevic opened this issue Jun 1, 2025 · 1 comment · Fixed by #80048
Labels
Depth Documentation issue which refers to a need for a deeper explanation, or precision

Comments

@ChristianIvicevic
Copy link
Contributor

ChristianIvicevic commented Jun 1, 2025

What is the documentation issue?

In a fairly recent change in #78769 the docs were updated claiming that images from the public directory don't require explicit sizes:

return (
<Image
src="/profile.png"
alt="Picture of the author"
// width={500} automatically provided
// height={500} automatically provided
// blurDataURL="data:..." automatically provided
// placeholder="blur" // Optional blur-up while loading
/>
)

That information is, at the time of writing this, wrong and this behavior was never supported. It's possible this is part of an upcoming feature change in 15.4+, but right now it appears in the documentation of the current 15.3 version and is misleading new users.

Is there any context that might help us understand?

n/a

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/getting-started/images#local-images

@icyJoseph icyJoseph added the Depth Documentation issue which refers to a need for a deeper explanation, or precision label Jun 2, 2025
@icyJoseph
Copy link
Contributor

Hi,

Yeah, there's obviously a problem, as you are immediately confronted with an error overlay.

I think, the correct code should be:

import Image from 'next/image'
import ProfileImage from './profile.png';
 
export default function Page() {
  return (
    <Image
      src={ProfileImage}
      alt="Picture of the author"
      // width={500} automatically provided
      // height={500} automatically provided
      // blurDataURL="data:..." automatically provided
      // placeholder="blur" // Optional blur-up while loading
    />
  )
}

I'll double check and update the docs accordingly.

leerob added a commit that referenced this issue Jun 2, 2025
Closes:
https://linear.app/vercel/issue/DOC-4730/docs-nextimage-local-images-broken-snippet
Fixes: #80023

Made the static image imports, into a sub section of local images, and
referenced how their width/height is auto calculated.

-
https://github.com/vercel/next.js/blob/fde4f7f2974d5870a74c196383af70df981de39e/packages/next/src/shared/lib/get-img-props.ts#L397-L398
here we copy the dimensions for statically imported images

There's also some tests that reference this usage:

-
https://github.com/vercel/next.js/blob/00c52d1506638ed8a4e46ac97ad999454c4823d1/test/integration/next-image-new/base-path/pages/static-img.js#L23

---------

Co-authored-by: Lee Robinson <lee@leerob.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Depth Documentation issue which refers to a need for a deeper explanation, or precision
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants