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
Enable WebP images in WooCommerce #37307
Enable WebP images in WooCommerce #37307
Conversation
WebP files should be able to be imported in WooCommerce, as they've been supported in WordPress core since v5.8. Adding this pull request, based on the following comments: - woocommerce#28998 (comment) - woocommerce#28998 (comment) This is a first for me, hope all is in order. Cheers! 🙂
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.
@anastas10s-afk Thanks for submitting the PR. See my comments for the needed changes.
PS: I am aware that line 2609 could use alignment with the lines above it; can't see that I have an option to edit the code at this point in time, though.
A pull request isn't restricted to a single commit. If you notice you have missed something then you can fix it in your PR branch and push it to Github. Github will automatically update your PR.
The PR template has Closes # .
in it. The reason we have that in the template is that Github will automatically close the issue if the PR description has Closes #ISSUENUMBER
. Can you add that to your description.
Lastly, our process requires a changelog entry. You can create one with pnpm --filter=woocommerce changelog add
. If you don't have pnpm running in your dev environment, let me know and I can add the changelog entry for you.
return $mime_to_ext; | ||
} | ||
|
||
function wc_rest_allowed_image_mime_types() { |
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 function already exists: https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/includes/wc-rest-functions.php#L47:L59
Adding a second definition will cause a fatal error. You need to edit the original function.
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.
As I understand, I should go ahead with removing the whole function that I added (starting at line 2599), at wc-core-functions.php, and add 'webp' => 'image/webp',
in line 57 at wc-rest-functions.php.
Correct?
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.
I went ahead with doing so.
* | ||
* WebP files should be able to be imported in WooCommerce, as they've been supported in WordPress core since v5.8. | ||
*/ | ||
add_filter( 'woocommerce_rest_allowed_image_mime_types', 'more_mimes_to_exts' ); |
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 isn't necessary if you are already adding webp
to the array being passed to the filter.
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.
Just to clarify, it is suggested to remove line 2592. Correct?
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.
I went ahead with doing so.
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.
Just to clarify, it is suggested to remove line 2592.
There is no need for the more_mimes_to_exts
function as it was being called by the filter.
TIL, thank you for this @rrennick.
Happily! Just to clarify, that would be
Kindly go ahead with adding the changelog entry for me, please. I do not have pnpm running in your dev environment. Thank you! |
Removed, previously added, unnecessary filter, and already existing function in wc-rest-functions.php.
@anastas10s-afk Merging a PR closes it. The |
Noted. I went ahead with editing it to
@rrennick, as I understand the f2cd586 and bd2de5f commits are on point with fixing what is needed, and it is good to go? If otherwise, forgive me, could you reiterate on what would be needed from my end instead, please. Cheers! |
@anastas10s-afk Sorry if I wasn't clear. Adding
This needs to be addressed before the PR can be merged. |
I believe everything is set now, for the PR to be merged @rrennick. To summarize this PR, I went ahead with removing all additions I previously made in Cheers! |
any timeline on when this is live? |
@anastas10s-afk Could you merge the latest |
Happily ...if only I knew how to do so @rrennick. I cannot find my way around doing that merge, either the web interface or the desktop app, at GitHub. First-timer, my apologies. |
@rrennick any pointers would be very much appreciated, if possible. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## trunk #37307 +/- ##
==========================================
- Coverage 51.7% 51.6% -0.0%
Complexity 17257 17257
==========================================
Files 429 429
Lines 79765 79828 +63
==========================================
+ Hits 41200 41202 +2
- Misses 38565 38626 +61
|
Quick update on this, @rrennick. From what I gather, I was able to do so? |
@anastas10s-afk I did this for you earlier today. In the future the way you would do it is update |
Much appreciated, truly. A huge learning opportunity for me. Have a great one, @rrennick! |
All Submissions:
Changes proposed in this Pull Request:
WebP files should be able to be imported in WooCommerce, as they've been supported in WordPress core since v5.8.
Adding this pull request, based on the following comments:
This is a first for me, hope all is in order. Cheers! 🙂
PS: I am aware that line 2609 could use alignment with the lines above it; can't see that I have an option to edit the code at this point in time, though.
Closes #28998.
Other information:
pnpm --filter=<project> changelog add
?FOR PR REVIEWER ONLY: