[wp-trac] [WordPress Trac] #60354: Image filter functions strip query string from image src
WordPress Trac
noreply at wordpress.org
Fri Jan 26 15:14:35 UTC 2024
#60354: Image filter functions strip query string from image src
--------------------------+-----------------------------
Reporter: sanchothefat | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
The following 2 functions strip the query string from the image src found
in the content but it's not clear why this is done.
- wp_image_add_srcset_and_sizes:
https://github.com/WordPress/WordPress/blob/master/wp-
includes/media.php#L1708-L1715
- wp_img_tag_add_width_and_height_attr:
https://github.com/WordPress/WordPress/blob/master/wp-
includes/media.php#L2092-L2094
When using an external image service like Photon, Tachyon, or some other
integration that provides resizing via a query string this breaks the
generated srcset & sizes calculation, and can make the width and height
attributes use the original image dimensions when the same image file name
is used up to the start of the query string.
Take the following 2 image URL examples:
- https://example.com/images/kitten.jpg
- https://example.com/images/kitten.jpg?resize=300,200
The query string means these are 2 different images but those functions
will treat them both as the original.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60354>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list