Use art direction when viewport size needs different image content or crop.
When to Use
- Mobile and desktop use different assets
- Crop, focal point, or content hierarchy changes by viewport
- Carousel has separate mobile and desktop images
Goal
Render one correct image per viewport. Keep Next.js image optimization. Avoid loading unused images.
Rules
- Use
<picture>with<source>and final<img>. - Use
getImageProps()for each asset. - Share
altandsizes. - Make
altaccurate for all variants. - Order sources so first matching media query wins.
- Do not use
preloadorloading="eager". - Use
fetchPriority="high"for LCP image when needed. - Do not use
placeholderwithgetImageProps().
Pattern
import { getImageProps } from 'next/image'
export function HeroImage() {
const common = { alt: 'Mountain landscape', sizes: '100vw' }
const { props: { srcSet: desktop } } = getImageProps({
...common,
src: '/hero-desktop.jpg',
width: 1440,
height: 875,
})
const { props: { srcSet: mobile, ...rest } } = getImageProps({
...common,
src: '/hero-mobile.jpg',
width: 750,
height: 1334,
})
return (
<picture>
<source media="(min-width: 768px)" srcSet={desktop} />
<img {...rest} style={{ width: '100%', height: 'auto' }} />
</picture>
)
}
Flow
- Confirm content changes, not only size.
- Pick assets per breakpoint.
- Define common props.
- Generate
srcSetper asset. - Put
<source>before fallback<img>. - Test desktop, tablet, and mobile.
- Confirm only matching image loads.
Output
## Art Direction Plan
Use case: [why different images are needed]
Breakpoints:
- [media query]: [asset], [width]x[height]
- fallback: [asset], [width]x[height]
Common props:
- alt: [text]
- sizes: [value]
- priority: [fetchPriority if LCP]