Loading...
Loading...
Generate responsive image code for Hyvä Theme templates using the Media view model. This skill should be used when the user wants to render images in a Hyvä template, create responsive picture elements, add hero images, product images, or any image that needs responsive breakpoints. Trigger phrases include "render image", "add image to template", "responsive image", "picture element", "hero image", "responsive banner", "image for mobile and desktop", or "banner image".
npx skill4agent add hyva-themes/hyva-ai-tools hyva-render-media-image<picture>\Hyva\Theme\ViewModel\Mediapub/media/wysiwyg/hero.jpgcatalog/product/...$imageData$heroImagereferences/rendering-images.md## Image Configuration Formatreferences/rendering-images.md| Scenario | Pattern to Use |
|---|---|
| Single image, literal values | Single Image Example |
| Single image from variable | Wrap in array: |
| Multiple images from variable | Pass directly: |
| Different images for mobile/desktop | Responsive Images with Media Queries |
Need to style the | Picture Element Attributes |
<?php
/** @var \Hyva\Theme\ViewModel\Media $mediaViewModel */
$mediaViewModel = $viewModels->require(\Hyva\Theme\ViewModel\Media::class);
echo $mediaViewModel->getResponsivePictureHtml(
$images, // Array of image configs (see reference for format)
$imgAttributes, // Optional: alt, class, loading, fetchpriority
$pictureAttributes // Optional: class, data-* attributes for <picture>
);| Image Type | Attributes |
|---|---|
| Hero/LCP (above fold) | |
| Below fold | |
references/rendering-images.md