-
Notifications
You must be signed in to change notification settings - Fork 138
Fix: Moved column_count context from column block to columns block to ensure it is available to ancestor blocks
#2138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #2138 +/- ##
=======================================
Coverage 68.21% 68.21%
=======================================
Files 93 93
Lines 7947 7947
=======================================
Hits 5421 5421
Misses 2526 2526
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the 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. |
|
@felixarntz @joemcgill could you please take a look when you have moment! |
column_count context from column block to columns block to ensure it is available to ancestor blocks
|
@mukeshpanchal27 What is the expected impact of this change? I created a post with a Columns block as follows: Post Content<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column {"width":"25%"} -->
<div class="wp-block-column" style="flex-basis:25%"><!-- wp:image {"id":62,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="http://localhost:8000/wp-content/uploads/2025/07/Juraparc_06-07-2013_-_Buffalo_calf-1024x678.jpg" alt="" class="wp-image-62"/><figcaption class="wp-element-caption">Buffalo calf</figcaption></figure>
<!-- /wp:image --></div>
<!-- /wp:column -->
<!-- wp:column {"width":"50%"} -->
<div class="wp-block-column" style="flex-basis:50%"><!-- wp:image {"id":10,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="http://localhost:8000/wp-content/uploads/2025/06/American_bison_k5680-1-1-1024x668.jpg" alt="" class="wp-image-10"/></figure>
<!-- /wp:image --></div>
<!-- /wp:column -->
<!-- wp:column {"width":"25%"} -->
<div class="wp-block-column" style="flex-basis:25%"><!-- wp:image {"id":63,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src="http://localhost:8000/wp-content/uploads/2025/07/Bison_bison_Wichita_Mountain_Oklahoma-1024x741.jpg" alt="" class="wp-image-63"/></figure>
<!-- /wp:image --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->The rendered markup on the frontend is the same on <div
class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex"
>
<div
class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"
style="flex-basis: 25%"
>
<figure class="wp-block-image size-large">
<img
fetchpriority="high"
decoding="async"
width="1024"
height="678"
sizes="(max-width: 161px) 100vw, 161px"
src="http://localhost:8000/wp-content/uploads/2025/07/Juraparc_06-07-2013_-_Buffalo_calf-1024x678.jpg"
alt=""
class="wp-image-62"
srcset="
http://localhost:8000/wp-content/uploads/2025/07/Juraparc_06-07-2013_-_Buffalo_calf-1024x678.jpg 1024w,
http://localhost:8000/wp-content/uploads/2025/07/Juraparc_06-07-2013_-_Buffalo_calf-300x199.jpg 300w,
http://localhost:8000/wp-content/uploads/2025/07/Juraparc_06-07-2013_-_Buffalo_calf-768x509.jpg 768w,
http://localhost:8000/wp-content/uploads/2025/07/Juraparc_06-07-2013_-_Buffalo_calf-1536x1017.jpg 1536w,
http://localhost:8000/wp-content/uploads/2025/07/Juraparc_06-07-2013_-_Buffalo_calf-2048x1356.jpg 2048w
"
/>
<figcaption class="wp-element-caption">Buffalo calf</figcaption>
</figure>
</div>
<div
class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"
style="flex-basis: 50%"
>
<figure class="wp-block-image size-large">
<img
decoding="async"
width="1024"
height="668"
sizes="(max-width: 322px) 100vw, 322px"
src="http://localhost:8000/wp-content/uploads/2025/06/American_bison_k5680-1-1-1024x668.jpg"
alt=""
class="wp-image-10"
srcset="
http://localhost:8000/wp-content/uploads/2025/06/American_bison_k5680-1-1-1024x668.jpg 1024w,
http://localhost:8000/wp-content/uploads/2025/06/American_bison_k5680-1-1-300x196.jpg 300w,
http://localhost:8000/wp-content/uploads/2025/06/American_bison_k5680-1-1-768x501.jpg 768w,
http://localhost:8000/wp-content/uploads/2025/06/American_bison_k5680-1-1-1536x1002.jpg 1536w,
http://localhost:8000/wp-content/uploads/2025/06/American_bison_k5680-1-1-2048x1336.jpg 2048w
"
/>
</figure>
</div>
<div
class="wp-block-column is-layout-flow wp-block-column-is-layout-flow"
style="flex-basis: 25%"
>
<figure class="wp-block-image size-large">
<img
decoding="async"
width="1024"
height="741"
sizes="(max-width: 161px) 100vw, 161px"
src="http://localhost:8000/wp-content/uploads/2025/07/Bison_bison_Wichita_Mountain_Oklahoma-1024x741.jpg"
alt=""
class="wp-image-63"
srcset="
http://localhost:8000/wp-content/uploads/2025/07/Bison_bison_Wichita_Mountain_Oklahoma-1024x741.jpg 1024w,
http://localhost:8000/wp-content/uploads/2025/07/Bison_bison_Wichita_Mountain_Oklahoma-300x217.jpg 300w,
http://localhost:8000/wp-content/uploads/2025/07/Bison_bison_Wichita_Mountain_Oklahoma-768x556.jpg 768w,
http://localhost:8000/wp-content/uploads/2025/07/Bison_bison_Wichita_Mountain_Oklahoma-1536x1112.jpg 1536w,
http://localhost:8000/wp-content/uploads/2025/07/Bison_bison_Wichita_Mountain_Oklahoma-2048x1483.jpg 2048w
"
/>
</figure>
</div>
</div> |
@westonruter The intention of this change is to improve the accuracy of the In those cases, the editor currently doesn’t add a Example (current trunk): TT4 Theme
In both cases, it uses the columns default alignment width (620px), which is not correct in a multi-column layout. With this change (current branch) we calculate the
This results in more accurate image size selection and improves performance by avoiding unnecessarily large images. In your use-case ( |
|
@mukeshpanchal27 Thank you. I can confirm in a Columns block with two columns of equal widths, there is indeed a change: --- /tmp/before.html 2025-08-18 09:55:09
+++ /tmp/after.html 2025-08-18 09:55:23
@@ -10,7 +10,7 @@
decoding="async"
width="1024"
height="668"
- sizes="(max-width: 645px) 100vw, 645px"
+ sizes="(max-width: 322px) 100vw, 322px"
src="http://localhost:8000/wp-content/uploads/2025/06/American_bison_k5680-1-1-1024x668.jpg"
alt=""
class="wp-image-10"
@@ -33,7 +33,7 @@
decoding="async"
width="1024"
height="741"
- sizes="(max-width: 645px) 100vw, 645px"
+ sizes="(max-width: 322px) 100vw, 322px"
src="http://localhost:8000/wp-content/uploads/2025/07/Bison_bison_Wichita_Mountain_Oklahoma-1024x741.jpg"
alt=""
class="wp-image-63" |

Summary
Fixes #2137
The columns block was not passing the column_count context to the column block, which caused the issue. This PR moves the column_count context to the columns block so it can be passed to its ancestor blocks.
Relevant technical choices