Skip to content

fix(php-transformer): keep aligned inline images inline-level - #1859

Merged
chubes4 merged 1 commit into
trunkfrom
fix/inline-image-figure-alignment
Sep 16, 2026
Merged

chubes4 merged 1 commit into
trunkfrom
fix/inline-image-figure-alignment

Conversation

@chubes4

@chubes4 chubes4 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Source images that the page aligned right or center were rendering flush left.

A bare <img> is inline content, so the parent's text-align decides where it sits:

<div class="wsite-image" style="text-align:right"><a><img src="…"></a></div>

Synthesizing a <figure> around it replaces that inline box with a block box that fills the line. The alignment was still emitted and still applied — it just had no inline content left to move, so the image sat at the left edge of a full-width figure.

Mark the synthesized figure inline-level in exactly that case.

Gating

The change is limited to images that were inline-level and whose inherited alignment acts on inline content:

source result
inline img, parent text-align:right/center inline-level figure
inline img, parent text-align:left unchanged block figure
img{display:block;margin:0 auto} unchanged block figure
authored <figure> never synthesized

A block image keeps its full-width figure deliberately: shrink-wrapping it would strip the width its auto margins resolve against.

Evidence

Annie home page, 1440px. Source image sits at x=180 in a right-aligned 50% column.

source before after
image x 180 120 180

Test plan

  • php php-transformer/tests/unit/synthetic-image-figure-inline-flow.php (6 assertions covering all four gate cases)
  • engine-support-css, engine-support-css-asset, image-lightbox-link-projection, image-carrier-hidden-label, media-text-pattern, cover-pattern, responsive-media-block
  • php php-transformer/tests/contract/run.php

AI assistance: grok-4.6 via OpenCode. Found by sweeping every page against the captured source served locally, then confirming the cause in a browser.

A bare img is inline content, so its parent's text-align decides where
it sits. Synthesizing a figure around it replaces that inline box with
a block box that fills the line, so a right or center alignment had
nothing left to move and every such image slid to the left edge.

Mark the synthesized figure inline-level in exactly that case. A block
image keeps its full-width figure, because shrink-wrapping it would
strip the width its auto margins resolve against.
@chubes4
chubes4 merged commit ccba27c into trunk Sep 16, 2026
10 checks passed
@chubes4
chubes4 deleted the fix/inline-image-figure-alignment branch September 16, 2026 21:09
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