Repository navigation
Paint an image's inline background on its leaf instead of dropping it - #7465
Merged
Merged
Conversation
chubes4
force-pushed
the
fix/7459-img-inline-background-image
branch
from
November 24, 2026 02:05
be77826 to
ea6862c
Compare
Contributor
Author
|
Note on |
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.
Fixes #7459.
Why
The Studio Bossa homepage paints its product photos ("Find your little Bossa.": Bossa Rio Table Lamp, Wave Vase) as atlas sprites. Each one is an
<img>with a transparent 1×1 placeholdersrc, and the inline style paints the real photo:Conversion dropped the
background-image.InlineGeometry::className()(php-transformer/src/HtmlToBlocks/Style/InlineGeometry.php:480-487on trunk) carries an inline url background only when the element has children or text, which an<img>never has.background-positionandbackground-sizestill came through, but only because they override an author rule (inlineAuthorOverrideDeclarations), and they ended up on the synthetic figure (StyleResolver::presentationAttributes($image, …)fromImageLowering::imagePresentationAttributes(),ImageLowering.php:949on trunk). The figure doesn't paint the image. The copiedrio-angles.jpg/wave-vase.webpassets were never referenced, so the cards showed up as empty boxes.The atlas is a sprite, so using it as the image
srcwould show the whole sheet. The background declaration has to stay, and it has to paint the image's own box. That box can differ from the figure's: here author rules give the leafheight:220px, and at narrow widthswidth:calc(100% + 2*gutter)plus negative inline margins.What changed
StyleResolver::imageLeafBackgroundProperties()(new): when an<img>'s inlinebackground/background-imagepaints an image (url(),image-set()or a gradient), it returns the inline background longhands present (background,-image,-position,-size,-repeat,-origin,-clip,-attachment,-blend-mode).StyleResolver::imageLeafPlacementClassName()forces those properties onto the existing image-leaf carrier (InlineGeometry::className(..., imageLeaf: true)). The carrier already targets.wp-block-image.X>img, keeps the inline-over-author tiering, and rewritesurl()throughresolvedAssetImageUrl().ImageLowering::imagePresentationAttributes()excludes the same properties from the synthetic figure's carrier, so the crop isn't split across two boxes.InlineGeometry::backgroundCarrierProperties()is now public, so there is still one list of background properties.Output change
Before (trunk), the figure carries the crop and there is no image:
After, the leaf paints the rewritten asset along with its crop:
On the imported site, the URL resolves to
themes/<slug>/assets/website/media/rio-angles.jpg(HTTP 200).Parity fixtures: unchanged (368 passed).
Evidence
Subset copy of the Bossa capture with
/, imported through Studio CLI using SSImain(7c1f5190) dev packages built against trunk85b9cf23baa(before) and this branch (after). Both were compared against the full capture with data-liberation 0.41.3compare --screenshots.pixel region 0,12624 390x480 (74 tiles) in core/group;96,13296 240x240 (22 tiles)pixel region 0,12624 768x912 (206 tiles) in core/group;144,13728 480x288 (48 tiles)pixel region 528,12432 384x432 (57 tiles) in core/group;960,12432 144x240 (14 tiles)All other regions at each width are identical between before and after. The remaining failures (internal-link 404s from the subset, the Δ10 page height, small text tiles) are unrelated. Visually, the lamp and vase cards now match the source screenshot at 768 and 1440.
Editor: opening the imported homepage in the block editor shows 344 blocks with 0 invalid, both atlas
core/imageblocks are valid, and the editor canvas paintsrio-angles.jpg/wave-vase.webpon the images.Tests
tests/unit/image-inline-background-paint-rides-leaf.php: fails on trunk ("the inline background-image must paint the converted image leaf"), passes here. It checks that the leaf gets the asset and its crop and that the figure paints nothing.composer lint: OK (PHPCS + PHPStan).php tests/parity/run.php: 368 fixtures passed.php tests/run.php: 2010 tests. 5 fail locally (artwork-slideshow,component-interactions,positioned-carousel-stage,header-button-box,shared-chrome-corpus), and they fail the same way on unmodified trunk in this PHP 8.5 environment.AI disclosure: implemented by Claude (Opus) as a Franklin/Pi subagent; Chris Huber directed the work.