[wp-trac] [WordPress Trac] #60354: Image filter functions strip query string from image src
WordPress Trac
noreply at wordpress.org
Fri Jan 26 20:25:49 UTC 2024
#60354: Image filter functions strip query string from image src
--------------------------+------------------------------
Reporter: sanchothefat | Owner: joemcgill
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: Awaiting Review
Component: Media | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by joemcgill):
Hey @sanchothefat! These functions were designed to use the image src to
try to match the markup with one of the image files stored on the
filesystem, by comparing them to file paths stored in attachment metadata.
In the case of `srcset`, this was to ensure that we are only including
different dimensions of the same image in the source list, and not any
cropped variations that would change the intended display of the image at
different breakpoints.
For services that are doing dynamic generation of image sizes, you likely
don't need to rely on WP to generate the srcset sizes, since you have the
ability to generate your own list of sources on the fly. Jetpack, for
example,
[https://github.com/Automattic/jetpack/blob/18e6d15c97f34b5d40801d9791d537557c9c294e/projects/packages
/image-cdn/src/class-image-cdn.php#L114-L115 filters the srcset values]
calculated by WP in order to serve sizes from their CDN.
I think the available filters would allow you to optimize these values
even more effectively than what WP is able to do out of the box, but if
there are things we could do to make that easier, feel free to make
suggestions. Hope that explanation helps.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60354#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list