Skip to content
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

Switch to wp_content_img_tag filter for Improved Image Handling #1772

Merged

Conversation

b1ink0
Copy link
Contributor

@b1ink0 b1ink0 commented Jan 3, 2025

Summary

Fixes #1259

Relevant technical choices

This PR updates the image processing approach by transitioning from the use of the the_content filter to the wp_content_img_tag filter.

Copy link

github-actions bot commented Jan 3, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: b1ink0 <b1ink0@git.wordpress.org>
Co-authored-by: felixarntz <flixos90@git.wordpress.org>
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: joemcgill <joemcgill@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@mukeshpanchal27 mukeshpanchal27 added [Type] Enhancement A suggestion for improvement of an existing feature [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) no milestone PRs that do not have a defined milestone for release labels Jan 3, 2025
Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@b1ink0 Thanks for the PR! Looks almost good to go to me, only a few points on the new function.

Comment on lines 521 to 522
* @since 1.0.0
* @since n.e.x.t Added the `$context` and `$attachment_id` parameters.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really is a new function as it is incompatible with the old function signature. So we should mark it as such, it's more than a change to the existing function.

$content = '';
}

function webp_uploads_update_image_references( string $filtered_image, string $context, int $attachment_id ): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the signature is already not compatible with the old function, we can also come up with a better name given the different usage. For example webp_uploads_filter_image_tag().

Copy link
Member

@adamsilverstein adamsilverstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! +1 to renaming suggested by Felix.

Copy link
Member

@adamsilverstein adamsilverstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@felixarntz felixarntz added this to the webp-uploads n.e.x.t milestone Jan 6, 2025
@felixarntz felixarntz removed the no milestone PRs that do not have a defined milestone for release label Jan 6, 2025
@felixarntz felixarntz merged commit 268ce65 into WordPress:trunk Jan 6, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve image handling approach in Modern Image Formats
4 participants