Skip to content

Commit fc476ed

Browse files
flacoonbandi34
authored andcommitted
fix: Correct photo numbering in photostrip layouts (2x4, 2x3)
- Photostrip layouts duplicate photos (left/right halves are cut) - Second half now shows numbers 1-4/1-3 again (not 5-8/4-6) - Display: Left: 1,2,3,4 | Right: 1,2,3,4 (duplicates) - Logic checks if layout is photostrip and resets numbering - Normal layouts (2+2, 1+3, etc.) unaffected
1 parent 33c5337 commit fc476ed

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

template/components/collageSelection.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,25 @@ function getLayoutPreviewSvg(CollageLayoutEnum $layout): string
8181
// Scale factor for SVG preview (typically /10 for nice numbers)
8282
$scale = 0.1;
8383

84+
// Check if this is a photostrip layout (2x4 or 2x3) where photos are duplicated
85+
$isPhotostrip = in_array($layout, [
86+
CollageLayoutEnum::TWO_X_FOUR_1,
87+
CollageLayoutEnum::TWO_X_FOUR_2,
88+
CollageLayoutEnum::TWO_X_FOUR_3,
89+
CollageLayoutEnum::TWO_X_FOUR_4,
90+
CollageLayoutEnum::TWO_X_THREE_1,
91+
CollageLayoutEnum::TWO_X_THREE_2,
92+
]);
93+
94+
// Calculate how many unique photos (half of total for photostrips)
95+
$layoutCount = count($layoutData['layout']);
96+
$uniquePhotoCount = $isPhotostrip ? (int)($layoutCount / 2) : $layoutCount;
97+
8498
// Process each photo position from layout array
8599
$positions = [];
86100
$photoNum = 1;
87101

88-
foreach ($layoutData['layout'] as $photoLayout) {
102+
foreach ($layoutData['layout'] as $index => $photoLayout) {
89103
// photoLayout format: [x, y, width, height, rotation, ?frame]
90104
if (count($photoLayout) < 4) {
91105
continue;
@@ -96,16 +110,27 @@ function getLayoutPreviewSvg(CollageLayoutEnum $layout): string
96110
$w = evaluateLayoutExpression($photoLayout[2], $width, $height);
97111
$h = evaluateLayoutExpression($photoLayout[3], $width, $height);
98112

113+
114+
// For photostrips: reset numbering after first half
115+
$displayNum = $isPhotostrip && $index >= $uniquePhotoCount
116+
? ($index - $uniquePhotoCount + 1)
117+
: $photoNum;
118+
99119
// Scale to SVG coordinates
100120
$positions[] = [
101121
'x' => $x * $scale,
102122
'y' => $y * $scale,
103123
'w' => $w * $scale,
104124
'h' => $h * $scale,
105-
'num' => $photoNum,
125+
'num' => $displayNum,
106126
];
107127

108-
$photoNum++;
128+
// Only increment if not in second half of photostrip
129+
if (!$isPhotostrip || $index < $uniquePhotoCount - 1) {
130+
$photoNum++;
131+
} elseif ($index === $uniquePhotoCount - 1) {
132+
$photoNum = 1; // Reset for second half
133+
}
109134
}
110135
}
111136

0 commit comments

Comments
 (0)