Skip to content
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

BUG: Replacing an image with an SVG leads to "division by zero" #4752

Closed
1 task done
dlubitz opened this issue Nov 15, 2023 · 0 comments · Fixed by #4753
Closed
1 task done

BUG: Replacing an image with an SVG leads to "division by zero" #4752

dlubitz opened this issue Nov 15, 2023 · 0 comments · Fixed by #4753
Assignees

Comments

@dlubitz
Copy link
Contributor

dlubitz commented Nov 15, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

If yor try to replace an image in the media module, that already contains variants, with an other image, the AssetService tries to refit the new image.

In case the new image is an SVG no height or wight is provided to calculate the aspect ratio nor new dimensions. This leads to a "division by zero" error in the adjustment:

public function refit(ImageInterface $image): void
{
$this->x = 0;
$this->y = 0;
$ratio = $this->getWidth() / $image->getWidth();
$this->setWidth($image->getWidth());
$roundedHeight = (int)round($this->getHeight() / $ratio, 0);
$this->setHeight($roundedHeight);
if ($this->getHeight() > $image->getHeight()) {
$ratio = $this->getHeight() / $image->getHeight();
$roundedWidth = (int)round($this->getWidth() / $ratio, 0);
$this->setWidth($roundedWidth);
$this->setHeight($image->getHeight());
}

Expected Behavior

No refit if a replacement with a SVG is processed.

Steps To Reproduce

  • add image to media library
  • ensure variants are created (resize/crop)
  • replace this image with an SVG

Environment

- Flow: 7.3
- Neos: 7.3
- PHP: 8.1

Anything else?

No response

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

Successfully merging a pull request may close this issue.

1 participant