alleyinteractive / alleyinteractive/wp-asset-manager

Add support for preloading responsive images

未关闭
#55 0 条评论 0 个 reaction 已指派 1 人 已被 @renatonascalves 认领 在 GitHub 查看
enhancement php
主要语言
PHP
星标
30
派生
5
PR 合并指标
30 天内没有已合并 PR

描述

### Description

`` now supports responsive image resource hints.

https://web.dev/preload-responsive-images/

We should add support for declaring `imagesrcset` and `imagesizes` attributes when preloading responsive images.

Example based on the article's example:

```php
am_preload(
[
'handle' => 'preload-wolf',
'src' => 'wolf.jpg',
'version' => '1.0.0',
'as' => 'image'
'mime_type' => 'image/jpeg',
'imagesrcset' => 'wolf_400px.jpg 400w, wolf_800px.jpg 800w, wolf_1600px.jpg 1600w',
'imagesizes' =>'50vw',
]
);
```

Alternatively, we may find declaring `imagesrcset` as an array beneficial:

```php
am_preload(
[
'handle' => 'preload-wolf',
'src' => 'wolf.jpg',
'version' => '1.0.0',
'as' => 'image'
'mime_type' => 'image/jpeg',
'imagesrcset' => [
400 => 'wolf_400px.jpg',
800 => 'wolf_800px.jpg',
1600 => 'wolf_1600px.jpg',
],
'imagesizes' =>'50vw',
]
);
```

### Use Case

The linked article has a few examples of use-cases. One we recently ran up against is preloading a hero image to reduce LCP.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。