Skip to content

Commit

Permalink
ImageColumns - Fix calculating container size in pixels (container = …
Browse files Browse the repository at this point in the history
…maincolwidth - 2*outergutter)
  • Loading branch information
mrdoinel committed Jul 25, 2024
1 parent 75b0e77 commit fd18822
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Services/ImageColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit fd18822

Please sign in to comment.