fix(php-transformer): keep aligned inline images inline-level - #1859
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Source images that the page aligned right or center were rendering flush left.
A bare
<img>is inline content, so the parent'stext-aligndecides where it sits: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:
text-align:right/centertext-align:leftimg{display:block;margin:0 auto}<figure>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.
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-blockphp php-transformer/tests/contract/run.phpAI assistance: grok-4.6 via OpenCode. Found by sweeping every page against the captured source served locally, then confirming the cause in a browser.