Skip to content

fix(php-transformer): fit slideshow slides into the recovered stage box - #1867

Merged
chubes4 merged 1 commit into
trunkfrom
fix/carousel-stage-contain
Sep 16, 2026
Merged

chubes4 merged 1 commit into
trunkfrom
fix/carousel-stage-contain

Conversation

@chubes4

@chubes4 chubes4 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Problem

#1858 recovered the stage box a slideshow framed its slides into, but inferred the wrong fit. It assumed each centered layer covered the box, so it took the smallest layer on each axis and cropped with object-fit: cover.

Measuring the source directly shows the opposite. For a stage whose real box is 885x590:

slide natural measured layer contain predicts cover predicts
portrait 729x1100 393x593 391x590 885x1335
landscape 1100x729 886x587 885x587 890x590

The layers are fitted inside the box and centred — a portrait slide is letterboxed, not cropped. So the box is the largest layer on each axis, not the smallest: 886x592 against a measured 885x590, inside half a percent.

The shipped inference produced a portrait 393/588 frame that cropped every landscape slide, and the stage also stretched to the full content column instead of its authored width.

Change

  • Reconstruct the box from the largest centered layer on each axis.
  • Fit slides with object-fit: contain, centred, so any orientation keeps one steady frame.
  • Bound the stage to its authored width (stageMaxWidth) and centre it, instead of filling the column.
  • An explicitly declared pixel height still wins and keeps its existing cover behaviour.

Test

php tests/unit/authored-carousel-block.php covers the recovered ratio and width, the emitted custom properties, the fitting stylesheet, declared-pixel-height precedence, and the uncentered-offset rejection. Full composer test passes locally, including all 311 parity fixtures.

AI assistance disclosure

Implemented with AI assistance — grok-4.6 via OpenCode. The correction came from measuring the live source's clip box and per-slide layer boxes against both fit models. A human retains review and merge authority.

The recovered box assumed each centered layer covered the stage, so it
took the smallest layer on each axis and cropped. Measuring the source
shows the opposite: the layers are fitted inside the box and centred, so
a portrait slide is letterboxed rather than cropped.

Take the largest layer on each axis, which reconstructs the box to within
half a percent, fit slides with object-fit contain, and bound the stage to
its authored width so it stops stretching to the content column.
@chubes4
chubes4 merged commit def4986 into trunk Sep 16, 2026
10 checks passed
@chubes4
chubes4 deleted the fix/carousel-stage-contain branch September 16, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant