New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce filter webp_uploads_pre_replace_additional_image_source
to short-circuit replacing additional image sources in frontend content
#319
Introduce filter webp_uploads_pre_replace_additional_image_source
to short-circuit replacing additional image sources in frontend content
#319
Conversation
modules/images/webp-uploads/load.php
Outdated
* @param string $target_mime The target mime in which the image should be created. | ||
* @param string $context The context where this is function is being used. | ||
*/ | ||
$image = (string) apply_filters( 'webp_uploads_pre_replace_additional_image_source', $image, $attachment_id, 'full', $target_mime, $context ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This filter should be placed above the line 510 and the code from str_replace
would be executed only if the image is different, take a look at suggested approach
here:
The full
value in this instance should be the name of the size being modified at this point in time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of tests would be great as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mitogh I have added changes as per your feedback in the latest commits.
Co-authored-by: Eugene Manuilov <manuilov@google.com>
Co-authored-by: Eugene Manuilov <manuilov@google.com>
When a modern format is available to render the featured image make sure that the replacement image uses the same logic used to replace the images in the content in order to be consistent with the rest of rendered format. Fixes #288
Hi there! Can we adjust the webp_uploads_pre_replace_additional_image_source filter code and doc block so it can be documented only one time and for other instances, we can add the below context as we use in WordPress?
Code changes that require for this. Replace this line https://github.com/WordPress/performance/blob/enhancement/replace-additional-image-filter/modules/images/webp-uploads/load.php#L503 code with Replace this whole doc block with https://github.com/WordPress/performance/blob/enhancement/replace-additional-image-filter/modules/images/webp-uploads/load.php#L516-L528 below context.
Pull request: #324 Please let me it and let me know your thoughts. |
Co-authored-by: Mukesh Panchal <mukeshpanchal27@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mehulkaklotar Production code looks good to me. I have two minor documentation suggestions, more importantly though the test here should be updated to be a more appropriate usage: The filter is for an image HTML tag, so it shouldn't be used to replace the image tag with just a URL.
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you @mehulkaklotar!
webp_uploads_pre_replace_additional_image_source
to short-circuit replacing image sources in frontend content
webp_uploads_pre_replace_additional_image_source
to short-circuit replacing image sources in frontend contentwebp_uploads_pre_replace_additional_image_source
to short-circuit replacing additional image sources in frontend content
Summary
Fixes #311
Relevant technical choices
Checklist
[Focus]
orInfrastructure
label.[Type]
label.no milestone
label.