From fd18822c4027c73526e8ffba2e3137fe29476654 Mon Sep 17 00:00:00 2001 From: Antoine Doury Date: Thu, 25 Jul 2024 14:15:15 +0200 Subject: [PATCH] ImageColumns - Fix calculating container size in pixels (container = maincolwidth - 2*outergutter) --- src/Services/ImageColumns.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Services/ImageColumns.php b/src/Services/ImageColumns.php index 58bc77c..f79fc08 100644 --- a/src/Services/ImageColumns.php +++ b/src/Services/ImageColumns.php @@ -149,7 +149,9 @@ protected function calcSize($size, $name) if (strrpos($size, 'px') > 0 || strrpos($size, 'vw') > 0 || strrpos($size, 'em') > 0) { $sizeAttr = $size; } elseif ($mainColWidth[0] !== 'auto') { - $width = round(((($mainColWidth[0] - ($columns - 1) * $innerGutter[0]) / $columns) * $size) + ($size - 1) * $innerGutter[0]); + // Must follow container calculation https://github.com/area17/tailwind-plugins/blob/main/src/Container/index.js + $container = $mainColWidth[0] - (2 * $outerGutter[0]); + $width = round(((($container - ($columns - 1) * $innerGutter[0]) / $columns) * $size) + ($size - 1) * $innerGutter[0]); $sizeAttr = $width . $mainColWidth[1]; } else { $gutterOffset = ((($columns - 1) * $innerGutter[0]) + (2 * $outerGutter[0])) . $innerGutter[1];