Loading...
Loading...
Compare original and translation side by side
<picture>\Hyva\Theme\ViewModel\Media\Hyva\Theme\ViewModel\Media<picture>pub/media/wysiwyg/hero.jpgcatalog/product/...$imageData$heroImagereferences/rendering-images.md## Image Configuration Formatpub/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>
);references/rendering-images.md| 场景 | 使用模式 |
|---|---|
| 单张图片,字面量值 | 单张图片示例 |
| 从变量获取单张图片 | 包装为数组: |
| 从变量获取多张图片 | 直接传入: |
| 移动端/桌面端使用不同图片 | 带媒体查询的响应式图片 |
需要为 | Picture元素属性 |
<?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 | |
| 图片类型 | 属性 |
|---|---|
| 首屏/LCP图片(首屏内) | |
| 首屏下方图片 | |
references/rendering-images.mdreferences/rendering-images.md