[BUGFIX] Fix image width calculation in ImageVariantsUtility.php#1501
Open
stephankellermayr wants to merge 4 commits intobenjaminkott:masterfrom
Open
[BUGFIX] Fix image width calculation in ImageVariantsUtility.php#1501stephankellermayr wants to merge 4 commits intobenjaminkott:masterfrom
stephankellermayr wants to merge 4 commits intobenjaminkott:masterfrom
Conversation
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:
```css
.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.
Contributor
Author
|
Great, since the bugs are piling up here and I was careless, PR #1453 has also crept in here. Anyway, probably nobody will take care of it in the foreseeable future anyway... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1500