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

Wrong image width calculation in ImageVariantsUtility.php #1500

Open
3 tasks done
stephankellermayr opened this issue Jul 28, 2024 · 0 comments · May be fixed by #1501
Open
3 tasks done

Wrong image width calculation in ImageVariantsUtility.php #1500

stephankellermayr opened this issue Jul 28, 2024 · 0 comments · May be fixed by #1501
Labels

Comments

@stephankellermayr
Copy link
Contributor

Bug Report

Prerequisites

  • Can you reproduce the problem on TYPO3 v11.5 LTS
  • Can you reproduce the problem on TYPO3 v12.4 LTS
  • Did you perform a cursory search
    to see if your bug or enhancement is already reported?

Description

Once again, a brilliant mathematician has pulled off a stroke of genius and caused the widths of the images not to be calculated correctly:

For example, the CSS states:

.textmedia-item, .textpic-item {
	width: calc(50% -(40px / 2));
}

Which, for example, leads to an image size of 620px with a container width of 1280px. logical, because $1280 * 0.5 - 40 / 2 = 620$

PHP produces the same result in this case, as the gutters are removed first and then the multiplier is applied.
Mathematically a different way, but in this case the same result: $(1280 - 40) * 0.5 = 620$

However, if a different multiplier is used, such as 25% instead of 50%, the situation is unfortunately different.
CSS calculates: $1280 * 0.25 - 40 / 2 = 300$
And PHP calculates: $(1280 - 40) * 0.25 = 310$

Ergo:
If you want to reflect the calculation of image/text widths used in SCSS in PHP code, you would first have to apply the multiplier and then subtract half the gutter.

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 a pull request may close this issue.

1 participant