nextjs-image-art-direction

Implement art direction for Next.js images using getImageProps() and the picture element.

5|Updated Oct 17, 2011
One-click install
npx skills add https://github.com/klen/dotfiles --skill nextjs-image-art-direction-klen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-image-art-direction
Source: https://github.com/klen/dotfiles/tree/main/.config/opencode/skills/nextjs-image-art-direction
Command: npx skills add https://github.com/klen/dotfiles --skill nextjs-image-art-direction-klen

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenge of displaying the most appropriate image asset based on the user's viewport size, ensuring optimal visual presentation and performance across devices.

Core Features & Use Cases

  • Art Direction: Serve entirely different images for different screen sizes (e.g., mobile vs. desktop).
  • Responsive Images: Serve the same image scaled appropriately for different screen sizes.
  • Use Case: Implement a homepage carousel that shows a mobile-optimized, vertically cropped image on small screens and a wide, horizontally cropped image on large screens, both conveying the same core message.

Quick Start

Use the nextjs-image-art-direction skill to implement art direction for the hero image on the homepage.

Frequently Asked Questions about nextjs-image-art-direction

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement art direction for responsive images in Next.js?

Implement art direction for responsive images in Next.js using the `getImageProps()` function combined with the native `<picture>` and `<source>` elements to serve distinct image assets based on viewport size.

What is the difference between responsive images and art direction in web performance?

Art direction serves entirely different image compositions for different screen sizes, whereas responsive images typically serve the same image scaled appropriately to optimize visual fidelity and loading performance.

How do I serve different image crops for mobile and desktop breakpoints in Next.js?

Serve different image crops for mobile and desktop breakpoints in Next.js by utilizing the `getImageProps()` function to generate attributes for multiple `<source>` elements within a `<picture>` tag, ensuring correct fallback matching.

Does Next.js `getImageProps()` support the native `<picture>` element?

Yes, the `getImageProps()` function in Next.js supports the native `<picture>` element by generating the necessary properties to populate multiple `<source>` tags for distinct viewport breakpoints.

When do I need to use different image assets for different viewport sizes?

You need to use different image assets for different viewport sizes when you require distinct image content or composition for mobile, tablet, and desktop breakpoints to convey the same core message optimally.

What is the best way to optimize hero images for different screen sizes in Next.js?

The best way to optimize hero images for different screen sizes in Next.js is using `getImageProps()` with the `<picture>` element to serve mobile-optimized vertical crops and wide horizontal desktop crops, maximizing loading performance.