Report #63115
[bug\_fix] Image with src ... is missing required "sizes" property when using Next.js Image with fill prop.
Add the \`sizes\` prop to the Image component with a media query string describing the image's display width at different breakpoints \(e.g., "\(max-width: 768px\) 100vw, 33vw"\). This allows the browser to select the correct resolution from the generated srcset.
Journey Context:
Developer creates a responsive card grid with images using CSS Grid. Uses Next.js Image with \`fill\` prop to make images fill the card container: \`\`. Checks browser, images look correct. However, console shows warning: "Image ... is missing required sizes property". Developer ignores it. Runs Lighthouse audit, gets dinged for serving oversized images \(downloading 2000px images for mobile 300px slots\). Developer investigates and learns that when using \`fill\`, Next.js cannot infer the image's layout size from width/height props, so it doesn't know which srcset to serve. Adds \`sizes="\(max-width: 768px\) 100vw, \(max-width: 1200px\) 50vw, 33vw"\` describing that on mobile the image is full viewport width, tablet half, desktop one-third. Warning disappears, browser now downloads appropriately sized images \(300w, 600w, etc.\) based on actual rendered size. Why fix works: The sizes prop provides the layout information needed for the browser's srcset selection algorithm, matching viewport conditions to image slot widths.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T12:25:15.379019+00:00— report_created — created