benjaminkott / benjaminkott/bootstrap_package

[BUG] wrong image width calculation in ImageVariantsUtility.php

Open
#1,576 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
PHP
Stars
355
Forks
212
Avg merge
1h 4m
Merged PRs (30d)
31

Description

# Bug Report

## Prerequisites

* [X] Can you reproduce the problem on TYPO3 v11.5 LTS
* [X] Can you reproduce the problem on TYPO3 v12.4 LTS
* [X] Can you reproduce the problem on TYPO3 v13 LTS
* [X] Did you [perform a cursory search](https://github.com/issues?q=is%3Aissue+user%3Abenjaminkott+repo%3Abenjaminkott%2Fbootstrap_package)
to see if your bug or enhancement is already reported?

## Description

Unfortunately, there is (still) a calculation error regarding image widths in ImageVariantsUtility.php, which results in incorrect image widths for different sizes.

For example, the [CSS](https://github.com/benjaminkott/bootstrap_package/blob/7b7bb52c12431f44b3d73715054dfdf9139c89e5/Resources/Public/Scss/components/_textpic.scss#L45) 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 guide

No contributing guide indexed for this repository

Research direction

Start by locating ImageVariantsUtility.php and compare its image-width calculation with the SCSS rule in Resources/Public/Scss/components/_textpic.scss. Check the 50% and 25% examples from the report; done means PHP produces widths consistent with the SCSS calculation, including gutter handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
bootstrap, php
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.