Replace the featured image with WebP version when available#18
Replace the featured image with WebP version when available#18mehulkaklotar wants to merge 2 commits intoadamsilverstein:add/webp-uploadsfrom
Conversation
felixarntz
left a comment
There was a problem hiding this comment.
@mehulkaklotar Looks good!
One higher-level point of feedback though: This implementation works as a first iteration, and it may be good enough to land in core. However, I'm a bit wary about just reusing the existing regular expression logic to replace image URLs, since it is somewhat expensive and should be unnecessary here.
The different in this code (and any calls to wp_get_attachment_image() for that matter is that we can get the correct MIME type URLs right away since we're programmatically outputting the image. The approach to first use the wrong MIME types (e.g. JPEG) and only then replacing them with the correct MIME type (e.g. WebP) therefore feels inefficient to me.
But I realize this would be a more complex effort, and it would rely on more WordPress core functions supporting a MIME type specification - which will only land a bit later.
Good point, this is inefficient and we should really be updating these functions to accept a mime_type parameter/attribute directly and outputting the correct image. Let's land this as a first iteration to get the feature complete then remove this bit when we update core functions to use the new approach. |
|
@mehulkaklotar @adamsilverstein Could we close this in favor of taking care of this directly in the relevant core functions? We can work on that once the MIME type parameter is available for the post thumbnail functions. |
f5c73f6 to
f4033b6
Compare
PR: WordPress/performance#316