Consider this Next.js Image component usage:
import Image from 'next/image';
export default function Example() {
return (
<Image
src='/photo.jpg'
alt='Sample photo'
width={800}
height={600}
sizes='(max-width: 600px) 480px, 800px'
priority
/>
);
}What will the browser do regarding image loading and size?
Check the priority prop and the sizes attribute.
The priority prop makes the image load eagerly. The sizes attribute tells the browser to use 480px width for screens up to 600px wide, and 800px otherwise.
Choose the correct syntax to make an image responsive using Next.js Image component with automatic layout adjustment.
Check the correct prop types and layout values.
The layout='responsive' prop requires numeric width and height props to calculate aspect ratio. Option C uses correct types and layout.
Given this code:
import Image from 'next/image';
export default function Demo() {
return (
<Image
src='/landscape.jpg'
alt='Landscape'
width={0}
height={0}
style={{ width: '100%', height: 'auto' }}
/>
);
}Why does the page experience layout shift when the image loads?
Think about how Next.js reserves space for images.
Next.js requires numeric width and height to reserve space and prevent layout shift. Zero values mean no space reserved, so the layout jumps when the image loads.
Why should developers use Next.js Image component instead of a regular <img> tag for responsive images?
Think about performance and image delivery.
Next.js Image component optimizes images on demand, serves appropriate sizes based on device, supports lazy loading, and improves SEO by providing alt text and proper markup.
Given this component:
import Image from 'next/image';
export default function ResponsiveImg() {
return (
<Image
src='/banner.jpg'
alt='Banner'
width={1200}
height={400}
sizes='(max-width: 600px) 100vw, 50vw'
style={{ width: 'auto', height: 'auto' }}
/>
);
}On a screen 500px wide, what width will the image render?
Check the sizes attribute and screen width.
The sizes attribute says for screens up to 600px wide, use 100vw (full viewport width). On a 500px screen, 100vw equals 500px, so the image renders at 500px wide.