Opened 4 years ago
Last modified 4 years ago
#50944 new defect (bug)
wp_calculate_image_srcset can unintentionally include unscaled original image
Reported by: | fredrikll | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Media | Keywords: | 2nd-opinion |
Focuses: | Cc: |
Description
In wp-includes/media.php
, wp_calculate_image_srcset
seems to add the original image to the srcset string if the width is smaller than $max_srcset_image_width
and if the image isn't a GIF. This isn't desirable since the original image is uncompressed and I don't even think it's intentional.
This behavior seems to have been introduced in this patch: https://core.trac.wordpress.org/changeset/35561. From what I can tell, the if statement should read like this:
if ( ! isset( $image_sizes['thumbnail']['mime-type'] ) || 'image/gif' === $image_sizes['thumbnail']['mime-type'] ) {
The current code will include the original image whenever the thumbnail IS NOT a GIF. This seems to be opposite to the desired behavior?
Change History (6)
#1
@
4 years ago
- Component changed from General to Media
- Keywords needs-testing added
- Milestone changed from Awaiting Review to 5.5.1
- Version changed from trunk to 5.5
#4
@
4 years ago
@khag7 the refactor in [35561] actually seems to be the issue. If the relevant if
statement would still look like [35524], this bug would be fixed, from what I can tell.
The difference should be quite clear if one looks closer: isset( $image_sizes['thumbnail']['mime-type'] ) && 'image/gif' === $image_sizes['thumbnail']['mime-type']
versus ! isset( $image_sizes['thumbnail']['mime-type'] ) || 'image/gif' !== $image_sizes['thumbnail']['mime-type']
Thanks for the report @fredrikll and welcome. Moving this to 5.5.1 for investigation.