- Home
- Skills
- Flpbalada
- My Opencode Config
- Nextjs Image Art Direction
nextjs-image-art-direction_skill
136
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill flpbalada/my-opencode-config --skill nextjs-image-art-direction- SKILL.md8.7 KB
Overview
This skill implements art direction for Next.js images using getImageProps(). It shows entirely different image assets or crops per breakpoint rather than just scaling one file. Use it to deliver the right composition and optimized asset for each viewport while preserving accessibility and browser-native selection.
How this skill works
getImageProps() generates the srcSet and image props for each version without triggering React state, so you can build a <picture> with multiple <source> elements. Create one getImageProps() call per breakpoint (desktop, tablet, mobile), share common props like alt and sizes, then render <source media=... srcSet=.../> entries and a final <img> fallback. Avoid preload/loading="eager" and placeholder with this approach.
When to use it
- Homepage carousels that require distinct mobile and desktop assets
- Switching from landscape composition on desktop to portrait on mobile
- Different focal points or crops per breakpoint
- When mobile and desktop images are entirely different files
- When content hierarchy or visual emphasis changes between viewports
Best practices
- Share alt and sizes across all versions so accessibility and layout hints remain consistent
- Order <source> elements so the browser evaluates the intended breakpoint first (desktop-first or mobile-first depending on strategy)
- Use fetchPriority='high' for the LCP image instead of preload or loading='eager'
- Test on real devices and in devtools responsive mode to verify each breakpoint loads the correct asset
- Ensure every defined breakpoint has a valid image to avoid broken fallbacks
Example use cases
- Hero section: wide office scene on desktop, focused team shot on tablet, portrait subject on mobile
- Homepage carousel: high-res banner for desktop, square crop for mobile slides
- Product photography: full product shot on desktop, cropped detail on mobile
- Background images via CSS image-set() built from getImageProps() srcSet for responsive backgrounds
FAQ
Do not use preload or loading='eager' with art-directed sources because that forces all images to load. Use fetchPriority='high' on the shared props to prioritize the matching image.
How should I write alt text when images differ?
Write alt text that accurately describes the subject across all versions. It must remain true whether the viewer sees the desktop or mobile asset.