alleyinteractive / alleyinteractive/wp-asset-manager

Add support for preloading responsive images

Đang mở
#55 0 bình luận 0 reaction 1 người được giao Được @renatonascalves nhận Xem trên GitHub
enhancement php
Ngôn ngữ chính
PHP
Star
30
Fork
5
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### 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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.