Repository navigation
Post Featured Image: Fix alignment when a custom width is set - #84316
Mustafabharmal wants to merge 2 commits into
Conversation
🤖 PR meta 🤖🎉 PropsUnlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @parashshresh. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the |
im3dabasia
left a comment
There was a problem hiding this comment.
Thanks! The root cause checks out, and following the File and Image blocks keeps this consistent. A few things to check:
- Did you manage to test the empty placeholder, when a post has no featured image and a custom width is set? Does it move with the alignment in the editor?
- How does a custom width look with an overlay or gradient? Does the overlay cover only the image, or the whole block?
- With Align left and Align right, does text wrap beside the image, or does the image only move to that side?
- Could you check this in a right-to-left language, to confirm left and right stay on their physical sides?
|
Thanks for the review, @im3dabasia! I checked each point:
|

What?
Fixes #37936
When a custom width is set on the Featured Image block, choosing an alignment from the toolbar has no visible effect: the image stays on the left (or on the right in RTL languages). This is most noticeable inside the Query Loop's Post Template.
Why?
The custom width is applied to the inner
<img>(via thedimensionsselector), while the alignment class is applied to the<figure>wrapper. The wrapper stays full width (alignleft/alignrightare explicitly set towidth: 100%), so the wrapper is aligned but the image inside it isn't.How?
Add
text-alignrules for.aligncenter,.alignleftand.alignrighton the block wrapper, matching what the File and Image blocks already do. Left and right use/*rtl:ignore*/so they stay on their physical sides in RTL, consistent with core alignment behavior.This is a CSS-only change. There are no markup, attribute or PHP changes, so no deprecation is needed. Wide and full alignments are unaffected.
Testing Instructions
200px.Screenshots or screencast
Before.Featured.Image.Fix.mov
After.Featured.Image.Fix.mov
Use of AI Tools
I used Claude Code to look into the cause and draft the change and this description. I reviewed and tested the change myself.