-
Notifications
You must be signed in to change notification settings - Fork 219
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: +10 B (0%) Total Size: 1.53 MB
ℹ️ View Unchanged
|
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 work, @roykho! I really enjoyed the way you managed to dynamically generate cropped images instead of having to regenerate thumbnails for all of them. I've left some comments about the code.
I also noticed that the cropped image does not appear inside the Product Gallery dialog. I edited the template part related to the Product Gallery full-screen view, but the image is not cropped:
CleanShot.2023-10-27.at.16.35.45.mp4
57aaa24
to
4dfc0b2
Compare
4dfc0b2
to
d07f987
Compare
I will do a follow up PR to add e2e tests for this. |
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.
Awesome job, @roykho!
The Crop feature works smoothly and the code is uncomplicated.
I have just one change request, but otherwise, it's excellent!
Please also make sure to include the Changelog message.
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.
Thank you for addressing the issues, I just tested and couldn't spot any issues so i'm approving the PR. Great work! 🚀
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 works as expected and doesn't produce PHP Warnings when no Product Image is set.
What
Fixes #10632
This PR adds the image crop support when the crop images to fit setting is enabled.
Why
Some merchants may want to display only square images uniformly so that we don't get any side effects from images that are different ratios which can cause the gallery slider to shift.
Note
Since the "Crop images to fit" setting is disabled by default, my goal here is to minimize unnecessary processing as much as possible. So my approach here is not to register any sizes by default. Only when the "Crop images to fit" setting is enabled, then it would check if the image attachment had the cropped image size metadata and file and if it doesn't exists, it would generate it "on-the-fly".
The crop size dimension will be determined by the smallest dimension of the original image size.
Testing Instructions
Please consider any edge cases this change may have, and also other areas of the product this may impact.
Screenshots or screencast
WooCommerce Visibility
Required:
Checklist
Required:
[type]
label or a[skip-changelog]
label.Conditional:
[skip-changelog]
label is not present).Changelog