hyva-render-media-image by hyva-themes/hyva-ai-tools
npx skills add https://github.com/hyva-themes/hyva-ai-tools --skill hyva-render-media-image使用 \Hyva\Theme\ViewModel\Media 视图模型为 Hyvä 主题模板生成响应式 <picture> 元素。
用户可以通过以下方式之一提供图片数据:
选项 A:直接提供值 - 向用户询问:
pub/media/ 中的位置(例如:wysiwyg/hero.jpg, catalog/product/...)广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
选项 B:PHP 变量 - 用户提供一个变量名(例如:$imageData, $heroImage)。告知用户在 references/rendering-images.md 文件中的 ## 图片配置格式 部分有文档说明所需的数组结构。
完整的 API 参考、代码示例和所有配置选项请参阅 references/rendering-images.md。
选择合适的模式:
| 场景 | 使用的模式 |
|---|---|
| 单张图片,字面值 | 单张图片示例 |
| 来自变量的单张图片 | 用数组包装:[$imageData] |
| 来自变量的多张图片 | 直接传递:$images |
| 为移动端/桌面端使用不同图片 | 使用媒体查询的响应式图片 |
需要为 <picture> 包装器添加样式 | 图片元素属性 |
基础模板:
<?php
/** @var \Hyva\Theme\ViewModel\Media $mediaViewModel */
$mediaViewModel = $viewModels->require(\Hyva\Theme\ViewModel\Media::class);
echo $mediaViewModel->getResponsivePictureHtml(
$images, // 图片配置数组(格式见参考文档)
$imgAttributes, // 可选:alt, class, loading, fetchpriority
$pictureAttributes // 可选:用于 <picture> 的 class, data-* 属性
);
| 图片类型 | 属性 |
|---|---|
| 横幅/LCP(首屏) | 'loading' => 'eager', 'fetchpriority' => 'high' |
| 首屏以下内容 | 'loading' => 'lazy' |
references/rendering-images.md - 包含方法签名、所有配置选项、代码示例和最佳实践的完整 API 参考每周安装量
170
代码仓库
GitHub 星标数
59
首次出现
2026年1月27日
安全审计
安装于
github-copilot167
opencode163
codex163
gemini-cli158
amp157
kimi-cli157
Generate responsive <picture> elements for Hyvä Theme templates using the \Hyva\Theme\ViewModel\Media view model.
The user may provide image data in one of these ways:
Option A: Direct values - Ask the user for:
pub/media/ (e.g., wysiwyg/hero.jpg, catalog/product/...)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.
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>
);
| Image Type | Attributes |
|---|---|
| Hero/LCP (above fold) | 'loading' => 'eager', 'fetchpriority' => 'high' |
| Below fold | 'loading' => 'lazy' |
references/rendering-images.md - Complete API reference with method signature, all configuration options, code examples, and best practicesWeekly Installs
170
Repository
GitHub Stars
59
First Seen
Jan 27, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot167
opencode163
codex163
gemini-cli158
amp157
kimi-cli157
ESLint迁移到Oxlint完整指南:JavaScript/TypeScript项目性能优化工具
1,600 周安装