Skip to content

Fix: #26973 Fatal error when Product Image size is not defined #26974

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

Merged
merged 2 commits into from
Feb 26, 2020

Conversation

lbajsarowicz
Copy link
Contributor

@lbajsarowicz lbajsarowicz commented Feb 21, 2020

Description (*)

When product image parameters does not contain image_width and image_height, call to getRatio ends up with fatal error. Fixed by fallback to 0 for value not set.

Related Pull Requests

N/A

Fixed Issues (if relevant)

  1. Fatal error on calling ImageFactory::create() for product_page_image_large #26973

Manual testing scenarios (*)

N/A - Covered with Unit Test

Questions or comments

Support

image
Solving this issue is supported by Mediotype

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Feb 21, 2020

Hi @lbajsarowicz. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

Copy link
Contributor

@eduard13 eduard13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lbajsarowicz, thank you for your contribution. Not sure that such fix will give us the expected result, and namely to display the image (placeholder).
The image won't be showing as it doesn't have any width and height.
Could you please correct me if I'm wrong?
Thank you.

@ghost ghost dismissed eduard13’s stale review February 22, 2020 14:08

Pull Request state was updated. Re-review required.

@lbajsarowicz
Copy link
Contributor Author

@eduard13 The problem I solved is related to Fatal Error when no image is available in the specified size. I verified that the only place where getRatio is being used is app/code/Magento/Catalog/view/frontend/templates/product/image_with_borders.phtml. When you verify that file, it's adding bottom padding for inline element:

<span class="product-image-wrapper"
          style="padding-bottom: <?= ($block->getRatio() * 100) ?>%;">

which sounds ridiculous for me. I don't know what was the purpose of returning width, height and especially ratio for image that has none of them (app/design/frontend/Magento/blank/etc/view.xml)

<image id="product_page_image_large" type="image"/>

For me - I should return null as getRatio but someone have introduced fallback to 1.0 and strict type return to float. Any further change would be backward incompatible.

Copy link
Contributor

@eduard13 eduard13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got your point, thanks.
So basically, my understanding is as far as you don't define the image sizes, you can't expect that the image would have some.

@magento-engcom-team
Copy link
Contributor

Hi @eduard13, thank you for the review.
ENGCOM-6959 has been created to process this Pull Request
✳️ @eduard13, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@eduard13 eduard13 added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Feb 23, 2020
@engcom-Alfa engcom-Alfa self-assigned this Feb 24, 2020
@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

@m2-assistant
Copy link

m2-assistant bot commented Feb 26, 2020

Hi @lbajsarowicz, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fatal error on calling ImageFactory::create() for product_page_image_large
5 participants