Report #24664
[bug\_fix] Image with src "..." is missing required "width" and "height" attributes or "fill" prop \(or layout shift/performance issues\)
Provide explicit \`width\` and \`height\` for known dimensions to prevent Cumulative Layout Shift \(CLS\), or use the \`fill\` prop with \`sizes\` and a parent container with \`position: relative\` for responsive images where dimensions are unknown. For remote images, configure remotePatterns in next.config.js.
Journey Context:
Developer imports \`Image\` from 'next/image' to display product images from an external CMS. They write \`\` without dimensions. Next.js throws an error during build or development saying width and height are required. The developer tries adding arbitrary values like width=\{500\} height=\{300\}, but the images are various aspect ratios, causing distortion. They try to fetch metadata to get dimensions, but it's async and complex. They search the Next.js Image docs and discover the \`fill\` prop. They wrap the Image in a div with \`position: 'relative'\` and explicit dimensions or aspect ratio, then use \`fill\` with \`style=\{\{objectFit: 'cover'\}\}\`. They also add the \`sizes\` prop for responsive breakpoints. The error resolves, and they configure the remote hostname in \`next.config.js\` under \`images.remotePatterns\` to allow optimization of external URLs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:48:33.924080+00:00— report_created — created