vercel/next.js · error · Error

Image with src "${src}" must use "width" and "height" proper

Error message

Image with src "${src}" must use "width" and "height" properties or "layout='fill'" property.

What it means

The legacy pages-router Image component throws when neither width+height nor layout='fill' is provided for a given src: it must know intrinsic dimensions to build the sizer element and prevent layout shift, so images without sizing info are rejected.

Source

Thrown at packages/next/src/client/legacy/image.tsx:1060

    } else if (layout === 'intrinsic') {
      // <Image src="i.png" width="100" height="100" layout="intrinsic" />
      wrapperStyle.display = 'inline-block'
      wrapperStyle.position = 'relative'
      wrapperStyle.maxWidth = '100%'
      hasSizer = true
      sizerStyle.maxWidth = '100%'
      sizerSvgUrl = `data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27${widthInt}%27%20height=%27${heightInt}%27/%3e`
    } else if (layout === 'fixed') {
      // <Image src="i.png" width="100" height="100" layout="fixed" />
      wrapperStyle.display = 'inline-block'
      wrapperStyle.position = 'relative'
      wrapperStyle.width = widthInt
      wrapperStyle.height = heightInt
    }
  } else {
    // <Image src="i.png" />
    if (process.env.NODE_ENV !== 'production') {
      throw new Error(
        `Image with src "${src}" must use "width" and "height" properties or "layout='fill'" property.`
      )
    }
  }

  let imgAttributes: GenImgAttrsResult = {
    src: emptyDataURL,
    srcSet: undefined,
    sizes: undefined,
  }

  if (isVisible) {
    imgAttributes = generateImgAttrs({
      config,
      src,
      unoptimized,
      layout,
      width: widthInt,

View on GitHub (pinned to 0eb3775416)

Solutions

  1. Provide width and height props, or use layout='fill' with the legacy next/image.
Defensive patterns

Strategy: validation

When it happens

Trigger: The legacy next/image is missing sizing props.

Common situations: Using next/legacy/image without width/height or layout='fill'.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/e0aceb8494bf84ef. Report an issue: GitHub.