Add the new source data to the media REST API endpoint#3025
Add the new source data to the media REST API endpoint#3025mukeshpanchal27 wants to merge 5 commits into
source data to the media REST API endpoint#3025Conversation
felixarntz
left a comment
There was a problem hiding this comment.
@mukeshpanchal27 This looks off to a great start. I left some feedback on some nit-pick code improvements, but the most important thing here is about how to handle the full size, similar to what I mentioned in the plugin PR.
|
@mukeshpanchal27 I've added the Trac ticket link to https://core.trac.wordpress.org/ticket/55443 since that should be committed as part of that ticket, as a follow-up to https://core.trac.wordpress.org/changeset/53751. |
aaemnnosttv
left a comment
There was a problem hiding this comment.
Looking good @mukeshpanchal27 ! I left a few suggestions around the tests for your consideration. Someone else should be the one to approve this though 😄
| // WebP may not be supported by the server, in which case it will be stripped from the results. | ||
| if ( wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { | ||
| foreach ( $mime_types as $mime_type ) { |
There was a problem hiding this comment.
Is this entire block only relevant when webp is supported or would this only apply when $mime_type === 'image/webp'? Are these assertions not also valuable for image/jpeg?
Ideally I think we could remove the conditional here by setting up the test in a way where we control the support in a predictable way E.g. it_should_allow_the_upload_of_a_web_p_image_if_at_least_one_editor_supports_the_format
Then maybe we would have two separate test cases: one for where it is supported and one where it is not 🙂
There was a problem hiding this comment.
I have adjusted the WebP support conditions so if the server does not support WebP, then the test only tests the image/jpeg mime type.
Does it make sense, or do I need to add two separate test cases?
mehulkaklotar
left a comment
There was a problem hiding this comment.
@mukeshpanchal27 all changes looks good, I have one comment about using referenced variables in loop. Please have a look.
felixarntz
left a comment
There was a problem hiding this comment.
@mukeshpanchal27 Great work! This is looking almost good to commit. Only a few tiny nit-picks left to address.
felixarntz
left a comment
There was a problem hiding this comment.
@mukeshpanchal27 Just one tiny thing, other than that this looks great!
felixarntz
left a comment
There was a problem hiding this comment.
Excellent, thank you @mukeshpanchal27!
|
Committed to I made just one small tweak I realized last minute: It's safer to use the actual image URL from |
The PR adds new source data to the media REST API endpoint.
Trac ticket: https://core.trac.wordpress.org/ticket/55443
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.