hyva-render-media-image

hyva-themes/hyva-ai-tools · updated Apr 8, 2026

$npx skills add https://github.com/hyva-themes/hyva-ai-tools --skill hyva-render-media-image
0 commentsdiscussion
summary

Generate responsive <picture> elements for Hyvä Theme templates using the \Hyva\Theme\ViewModel\Media view model.

skill.md

Hyvä Render Image

Generate responsive <picture> elements for Hyvä Theme templates using the \Hyva\Theme\ViewModel\Media view model.

When to Use

  • Adding images to Hyvä PHTML templates
  • Creating responsive images with different sources for mobile/desktop
  • Implementing hero banners, product images, or CMS content images
  • Optimizing images for Core Web Vitals (LCP, CLS)

Workflow

1. Gather Image Requirements

The user may provide image data in one of these ways:

Option A: Direct values - Ask the user for:

  1. Image path(s) - Location in pub/media/ (e.g., wysiwyg/hero.jpg, catalog/product/...)
  2. Image dimensions - Width and height in pixels
  3. Responsive requirements - Different images for mobile vs desktop?
  4. Image purpose - Hero/LCP image (eager loading) or below-fold (lazy loading)?
  5. Alt text - Meaningful description for accessibility

Option B: PHP variable - The user provides a variable name (e.g., $imageData, $heroImage). Inform the user of the required array structure documented in references/rendering-images.md under ## Image Configuration Format.

2. Generate the Code

Refer to references/rendering-images.md for the complete API reference, code examples, and all configuration options.

Choose the appropriate pattern:

Scenario Pattern to Use
Single image, literal values Single Image Example
Single image from variable Wrap in array: [$imageData]
Multiple images from variable Pass directly: $images
Different images for mobile/desktop Responsive Images with Media Queries
Need to style the <picture> wrapper Picture Element Attributes

Base template:

<?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>
);

3. Set Loading Strategy

Image Type Attributes
Hero/LCP (above fold) 'loading' => 'eager', 'fetchpriority' => 'high'
Below fold 'loading' => 'lazy'

Resources

  • references/rendering-images.md - Complete API reference with method signature, all configuration options, code examples, and best practices

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.546 reviews
  • Diego Patel· Dec 28, 2024

    hyva-render-media-image is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Hana Chawla· Dec 20, 2024

    Useful defaults in hyva-render-media-image — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Chinedu White· Dec 12, 2024

    We added hyva-render-media-image from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Chaitanya Patil· Dec 8, 2024

    Useful defaults in hyva-render-media-image — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Piyush G· Nov 27, 2024

    hyva-render-media-image has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Yusuf Liu· Nov 19, 2024

    hyva-render-media-image fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Advait Liu· Nov 11, 2024

    hyva-render-media-image has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Rahul Santra· Nov 7, 2024

    Registry listing for hyva-render-media-image matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Yusuf Zhang· Nov 3, 2024

    Keeps context tight: hyva-render-media-image is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Pratham Ware· Oct 26, 2024

    hyva-render-media-image reduced setup friction for our internal harness; good balance of opinion and flexibility.

showing 1-10 of 46

1 / 5