benjaminkott / bootstrap_package

Bootstrap Package delivers a full configured theme for TYPO3, based on the Bootstrap CSS Framework.
https://www.bootstrap-package.com/
MIT License
338 stars 205 forks source link

Wrong image width calculation in ImageVariantsUtility.php #1500

Open stephankellermayr opened 3 months ago

stephankellermayr commented 3 months ago

Bug Report

Prerequisites

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.