humanmade / humanmade/tachyon-plugin

Create custom `srcset` attributes based on source image crop.

Open
#34 2 comments 3 reactions 0 assignees View on GitHub
enhancement
Dominant language
PHP
Stars
86
Forks
16
PR merge metrics
No merged PRs in 30d

Description

Currently the Tachyon Plugin builds the `srcset` attribute by replacing the sources WP core builds with Tachyon URLs. If the inserted image's aspect ratio doesn't match the ratio of any of the core image sizes (small, medium, etc) or an image size added by `add_image_size()` then the `srcset` is empty.

As Tachyon can recreate the source crop at any size up to that of the original image, a series of _sensible_ defaults can be used to generate the `srcset`. These sensible defaults can be based on common device screen resolutions.

```php
srcset_widths = [
640, // 320@2x
960, // 480@2x
$content_width * 2,
// etc
];
```

There are a few conditions in the core function `wp_calculate_image_srcset()` that we'd need to ensure we pass by applying a custom filter to `wp_calculate_image_srcset_meta`.

https://github.com/WordPress/wordpress-develop/blob/fd5ba80c5c3d9cf62348567073945e246285fbca/src/wp-includes/media.php#L1046-L1219

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.