[wp-trac] [WordPress Trac] #36477: Responsive images (srcset) can include images larger than the full size
WordPress Trac
noreply at wordpress.org
Wed Jun 5 18:46:41 UTC 2024
#36477: Responsive images (srcset) can include images larger than the full size
-------------------------------------------------+-------------------------
Reporter: peterdavehello | Owner: pbearne
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Future
| Release
Component: Media | Version: 4.4.2
Severity: normal | Resolution:
Keywords: has-patch needs-testing dev- | Focuses:
feedback needs-unit-tests | performance
-------------------------------------------------+-------------------------
Comment (by nosilver4u):
@adamsilverstein My patch mostly replaces that from @pbearne, but his has
the unit tests, though they may need some tweaking still. I'll let him
speak to that further so I'm not making commitments for him :)
As for WebP/AVIF, that doesn't solve the problem of reducing the palette
back to the original number of colors. I tested WebP, and while it does
admirably in some cases, it can still double or triple the file size
without the palette reduction in place.
With palette reduction included via quantizeImage(), the WebP file size is
even smaller than the resized & indexed PNGs, except for test8.png that
Imagick likes to force into grayscale mode rather than indexed. I don't
know what the equivalent fix is for WebP, but I had to force the PNG8
format for that particular case.
GD does suffer from the same issue, though it looks like there was a
potential fix, but it didn't work for me: https://github.com/WordPress
/wordpress-develop/blob/ac84bd53c6ab38cb6d808d30bc985ae84de2f0dc/src/wp-
includes/class-wp-image-editor-gd.php#L525
The imageistruecolor() and imagecolorstotal() functions should run on the
original image, and not the resized one, otherwise it doesn't convert the
image back to palette/indexed. But even when you do, transparency is
completely lost, so that's no good. That's as much as I care to mess with
GD, so I wouldn't block this for lack of a GD fix which may not even be
possible.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36477#comment:62>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list