-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Prevent resizing an image if it was already resized before #26801
Prevent resizing an image if it was already resized before #26801
Conversation
Hi @hostep. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
18fb215
to
c67e620
Compare
c67e620
to
9cc9844
Compare
Rebased on 2.4-develop and force pushed because 2 recent commits caused merge conflicts: |
9cc9844
to
406e071
Compare
Rebased and force pushed again to fix static tests (hopefully). |
c9d8235
to
bd695f3
Compare
bd695f3
to
2d1a3c1
Compare
Rebased again, because a new commit caused a merge conflict yet again: c093733 |
Hi @lenaorobei, thank you for the review. |
✔️ QA Passed Tested with File System and Database media storages Case 1.File System
✔️ The images didn't resize and the timestamp didn't change Case 2.DB media storage
✔️ The images didn't resize and the timestamp didn't change |
Hi @hostep, thank you for your contribution! |
We are on Magento 2.3.5-p2. This patch is a lifesaver when images are stored in the file system, however, it doesn't work when we have CDN (S3 Bucket) enabled for our website. Any help to fix it would be very helpful. |
@VivekShingala: can you open a new issue for this with as much information as possible like how you are connecting with S3 and such? Thanks! |
Hi @hostep This patch is working fine for Magento 2.3.5 but not for 2.3.2. Any solution for M2.3.2 available? |
What you can try is:
That's how I usually try to backport patches that can't be applied cleanly. |
Ow, you're in luck, it looks like we do have a patch for this for Magento 2.3.2, it's an earlier version of the commits I pushed here, but it probably works equally as well: Please test very well, no guarantees that it is flawless, but I think it should work ok if you don't store the media files in the database 🙂 |
Hi @hostep The patch you provided works perfectly on Magento 2.3.2 setup. Thank you very much. |
Description (*)
Images shouldn't get resized again if they were already resized before when running
bin/magento catalog:images:resize
.In Magento 2.1 they didn't get resized when they were already resized before. Somewhere between Magento 2.1.18 and 2.2.11 that got changed for some reason.
I also added some cleanup to that class in a second commit, because some use statements were missing meaningful aliases and some member variables weren't being used.
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
pub/media/catalog/product/cache/
bin/magento catalog:images:resize
pub/media/catalog/product/cache/
and check their modified timestampsbin/magento catalog:images:resize
againpub/media/catalog/product/cache/
and check their modified timestampsPlease also test when using media storage in the database, I haven't tested that but the code should work I believe.
Questions or comments
I know the unit tests will fail, will take a look later, not that much time currently. Feel free to pick this up yourselves, I don't mind 🙂- Update: Already DoneContribution checklist (*)