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

Introduce webp_uploads_get_content_image_mimes() to get content image MIME replacement rules #420

Merged
merged 7 commits into from Aug 10, 2022

Conversation

eugene-manuilov
Copy link
Contributor

@eugene-manuilov eugene-manuilov commented Jul 6, 2022

Summary

Originally intended as a fix to #414, but that issue isn't feasible to fix in the plugin, so now it's just a little API enhancement.

Relevant technical choices

Checklist

  • PR has either [Focus] or Infrastructure label.
  • PR has a [Type] label.
  • PR has a milestone or the no milestone label.

@eugene-manuilov eugene-manuilov added [Type] Enhancement A suggestion for improvement of an existing feature [Focus] Images Issues related to the Images focus area [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 Jul 6, 2022
Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

I have added some feedback regarding the doc block and code changes. PR 418 only allows a smaller version of an additional mime type image when this PR is merged. After that, this PR needs to be updated according to it.

modules/images/webp-uploads/load.php Outdated Show resolved Hide resolved
modules/images/webp-uploads/load.php Outdated Show resolved Hide resolved
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.

@eugene-manuilov I don't think we should address this in the plugin, as it isn't really an appropriate solution, since in core we should do this primarily based on a parameter - and not just replace the images but use the right images from the start. See #414 (comment) for more details.

With that said, you already put some work into this and I think breaking out the filter into a separate function and moving the unnecessary function call below the foreach loop are nice little improvements. So I'd say we can still merge this if we remove the new integrations around wp_get_image_attachment_src.


return $image;
}
add_filter( 'wp_get_attachment_image_src', 'webp_uploads_update_attachment_image_src', 10, 3 );
Copy link
Member

Choose a reason for hiding this comment

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

I think this is out of scope for the plugin, as functions controlled by developers should leave that control to developers. See #414 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me. Reverted it.

modules/images/webp-uploads/load.php Outdated Show resolved Hide resolved
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.

Thanks @eugene-manuilov! Will remove this PR from the issue since it doesn't really address it anymore, but rather is a nice little code enhancement.

@felixarntz felixarntz added this to the 1.3.0 milestone Jul 14, 2022
@felixarntz felixarntz removed the no milestone PRs that do not have a defined milestone for release label Jul 14, 2022
@felixarntz
Copy link
Member

@eugene-manuilov There are some merge conflicts here, can you look into those? This is not critical for the release since it's just a little code enhancement, so I'm going to move it to the next milestone.

@felixarntz felixarntz modified the milestones: 1.3.0, 1.4.0 Jul 14, 2022
@eugene-manuilov
Copy link
Contributor Author

@eugene-manuilov There are some merge conflicts here, can you look into those? This is not critical for the release since it's just a little code enhancement, so I'm going to move it to the next milestone.

@felixarntz, merge conflicts are fixed.

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!

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

@eugene-manuilov Just needs to correct the merge conflict.

@felixarntz felixarntz changed the title Updated image URLs returned from wp_get_attachment_image_src to use webp version if available Introduce webp_uploads_get_content_image_mimes() to get content image MIME replacement rules Aug 10, 2022
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.

@felixarntz felixarntz merged commit f4b8ee9 into trunk Aug 10, 2022
@felixarntz felixarntz deleted the enhancement/414-image-url-webp branch August 10, 2022 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Images Issues related to the Images focus area [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.

None yet

4 participants