humanmade / humanmade/tachyon-plugin
Create custom `srcset` attributes based on source image crop.
- 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.