-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Generetae thumbnails only if image have bigger size then defined in configuration, to aviod stretched images #29149
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
Generetae thumbnails only if image have bigger size then defined in configuration, to aviod stretched images #29149
Conversation
configuration, to aviod strechet images
Hi @Nazar65. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
@magento run alll tests |
@magento run all tests |
@magento run all tests |
/** | ||
* Return width height for the image resizing. | ||
* | ||
* @param string $source |
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.
Can you please define return param?
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.
but they already defined in strict types ? why need to duplicate it ?
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.
Agree. Despite its a requirement, i prefer to define a return type also, so for example
@return string[] or int[]
if ($imageWidth && $imageHeight) { | ||
$imageWidth = $configWidth > $imageWidth ? $imageWidth : $configWidth; | ||
$imageHeight = $configHeight > $imageHeight ? $imageHeight : $configHeight; | ||
} else { |
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.
Honestly I'm not a fan of "else" statement where they can be avoided, what about
if ($imageWidth && $imageHeight) {
$imageWidth = $configWidth > $imageWidth ? $imageWidth : $configWidth;
$imageHeight = $configHeight > $imageHeight ? $imageHeight : $configHeight;
return [$imageWidth, $imageHeight];
}
return [$configWidth, $configHeight];
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.
ok
|
||
list($imageWidth, $imageHeight) = $this->getResizedParams($source); | ||
|
||
$image->resize($imageWidth, $imageHeight); |
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.
Can you maybe drop some info here, do we still need a resize even if image size stays the same?
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.
yes, because we create a new image in thumbnail path, and other application expects image to be in thumbnails, and ignore thumbnail generation will be BIC changes.
@magento run all tests |
Hi @nuzil, thank you for the review. |
✔️ QA Passed Test on Cucumber Studio - https://studio.cucumber.io/projects/131313/test-plan/folders/1337102/scenarios/4968534 |
… defined in configuration, to aviod stretched images #29149
Hi @Nazar65, thank you for your contribution! |
Description (*)
Related Pull Requests
Fixed Issues (if relevant)
magento/adobe-stock-integration#1422 Small image is stretched all over the image thumbnail
Manual testing scenarios (*)
The image is not stretched and displayed as it is
Questions or comments
Contribution checklist (*)