| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Uses `image/webp` if supported by the client and updates the `image/jpeg`, `image/jpg` formats with the modern format if avaiable. References in the content are updated with the WebP format if available. Fixes #149
…e/149-update-the-content
…into feature/149-update-the-content
…into feature/149-update-the-content
…into feature/149-update-the-content
…into feature/149-update-the-content
Update the content from the sites using WebP images when available instead of JPEG or JPG images.
…into feature/149-update-the-content
The assertion would make sure both are not the same, meaning at least one has a different markup.
…into feature/149-update-the-content
|
This worked well in my testing across a variety of themes. The only issue I noticed was when inserting an image at the "large" size with a large image upload that results in a -scaled image, the jpeg is used for the image src, since the webp version isn't available yet (see #174). |
Sorry, something went wrong.
|
Thanks for taking the time to test it, currently this is expected and described here: performance/modules/images/webp-uploads/load.php Lines 414 to 417 in 7b38de8 Based on the decision from: The code would be updated accordingly if required. |
Sorry, something went wrong.
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
…/performance into feature/149-update-the-content
I noticed that as well, it depends on the viewport size and pixel density. Since we currently don't have WebP versions for the "full" size (whether -scaled or original), it's best to currently test this PR on a mobile viewport since there it's most likely to get served a WebP image. The problem is that most modern screens have a high pixel density like @2x, which means if I look at an image of 600px (or more accurately in a viewport of 600px), the browser will look for a size >=1200px, which would already be more than WordPress core's large by default. If you want to test this more specifically without the above caveats, you can put a temporary filter in place to ensure WordPress never chooses a size greater than the image size you actually specified (which may cause blurry images on larger or high-density devices though): add_filter(
'wp_calculate_image_srcset',
function( $sources, $size_array ) {
foreach ( $sources as $index => $source ) {
if ( 'w' === $source['descriptor'] && $source['value'] > $size_array[0] ) {
unset( $sources[ $index ] );
}
}
return $sources;
},
10,
2
);There's certainly room for optimization in core's default behavior there, but that's a separate rabbit hole :)
I agree this gives us an answer for #174, that we should also generate a WebP version of the full size. |
Sorry, something went wrong.
Move logic to replace image references into a separate function, update tests accordingly as well.
There was a problem hiding this comment.
@mitogh Great! I left a few follow-up comments, mostly minor though. This is almost ready.
Sorry, something went wrong.
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Adding `$context` parameter to match what core uses inside of `wp_filter_content_tags`
There was a problem hiding this comment.
This one open discussion is the only thing we need to finalize before we can merge this.
Sorry, something went wrong.
Update mechanism to use WP core mechanism to parse image tags inside of the content of the post.
|
Thanks, @felixarntz just updated to code to follow what WP Core uses in order to reduce the friction in the scenario this would be merged into WP Core. Let me know in case you have any additional feedback. |
Sorry, something went wrong.
There was a problem hiding this comment.
Awesome work @mitogh!
Sorry, something went wrong.
There was a problem hiding this comment.
Code looks great to me, thanks for the structural changes that will make prepping this for core more straightforward. Also retested and everything worked well in my testing.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Uses image/webp if supported by the client and updates the image/jpeg, image/jpg formats with the modern format if available.
References in the content are updated with the WebP format if available.
Fixes:
Related with:
Relevant technical choices
Checklist