From f9a49756a865e27c6e51424c2f344ff9df0de1ff Mon Sep 17 00:00:00 2001 From: Stephan Kellermayr Date: Tue, 12 Dec 2023 17:17:10 +0100 Subject: [PATCH 1/2] Added missing check whether the method initialise() exists --- Resources/Public/JavaScript/Src/bootstrap.cookieconsent.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Resources/Public/JavaScript/Src/bootstrap.cookieconsent.js b/Resources/Public/JavaScript/Src/bootstrap.cookieconsent.js index 44cf68004..03cb79cc5 100644 --- a/Resources/Public/JavaScript/Src/bootstrap.cookieconsent.js +++ b/Resources/Public/JavaScript/Src/bootstrap.cookieconsent.js @@ -140,8 +140,10 @@ window.addEventListener('DOMContentLoaded', function () { }; // Initialize - cookieConsentOptions.container = document.getElementById('cookieconsent'); - window.cookieconsent.initialise(cookieConsentOptions); + if (typeof window.cookieconsent.initialise === "function") { + cookieConsentOptions.container = document.getElementById('cookieconsent'); + window.cookieconsent.initialise(cookieConsentOptions); + } } }); From 77f33dccb7f8312c0b95fb1308810e76aeaa470a Mon Sep 17 00:00:00 2001 From: Stephan Kellermayr Date: Sun, 28 Jul 2024 22:36:22 +0200 Subject: [PATCH 2/2] Fixed image width calculation in ImageVariantsUtility.php 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. --- Classes/Utility/ImageVariantsUtility.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Classes/Utility/ImageVariantsUtility.php b/Classes/Utility/ImageVariantsUtility.php index a5e2526b2..4e685139a 100644 --- a/Classes/Utility/ImageVariantsUtility.php +++ b/Classes/Utility/ImageVariantsUtility.php @@ -67,12 +67,12 @@ public static function getImageVariants(?array $variants = null, ?array $multipl $variants = $variants !== null ? $variants : []; $variants = self::processVariants($variants); $variants = self::processResolutions($variants); - if ($gutters !== null) { - $variants = self::removeGutters($variants, $gutters); - } if ($multiplier !== null) { $variants = self::processMultiplier($variants, $multiplier); } + if ($gutters !== null) { + $variants = self::removeGutters($variants, $gutters); + } if ($corrections !== null) { $variants = self::processCorrections($variants, $corrections); } @@ -178,7 +178,7 @@ protected static function removeGutters(array $variants, array $gutters): array { foreach ($gutters as $variant => $value) { if (is_numeric($value) && $value > 0 && isset($variants[$variant]['width'])) { - $variants[$variant]['width'] = (int) ceil($variants[$variant]['width'] - (float) $value); + $variants[$variant]['width'] = (int) ceil($variants[$variant]['width'] - ((float) $value / 2)); } } return $variants;