Columns not working
Description
When adding a Gallery block with more than one image, the block still shows the column setting in the sidebar. However, changing the number of columns no longer affects the layout.
All images are rendered at full width, stacked vertically, both in the editor and on the front end. Previously, setting the Gallery block to multiple columns displayed the images next to each other as expected.
Step-by-step reproduction instructions
- Create a new post or page.
- Insert a Gallery block.
- Add at least two images to the Gallery block.
- Select the Gallery block.
- In the block sidebar, change the number of columns to 2 or more.
- Observe the layout in the editor.
- Publish or preview the post/page.
- Observe the layout on the front end.
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
- [x] Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- [x] Yes
Please confirm which theme type you used for testing.
- [x] Block
- [ ] Classic
- [ ] Hybrid (e.g. classic with theme.json)
- [ ] Not sure
Cannot Reproduce
Environment:
- Gutenberg: 23.3.2
- WordPress: 7.0
- Theme: Twenty Twenty-Five v1.5
- Browser: Chrome
- OS: macOS
Steps followed: Followed the reproduction steps exactly as described.
Result: Could not reproduce the reported behavior. The Gallery block's column setting is functioning correctly in my environment.
Image 1 — Editor view (3 images, columns set to 3): The Gallery block sidebar shows columns set to 3, and all three images render side by side in a single row inside the editor canvas as expected.
Image 2 — Frontend / published page: After publishing, the frontend also correctly renders all 3 images in 3 columns, confirming the column setting persists and renders as expected.
Could the reporter please share their Gutenberg and WordPress version, theme name, and any active plugins? It's possible this may be environment-specific or a theme CSS conflict overriding the Gallery block's column styles.
Update: I found the cause in my theme.
My theme.json contained:
{
"styles": {
"spacing": {
"blockGap": "0"
}
}
}
Changing this to 0px fixes the issue:
{
"styles": {
"spacing": {
"blockGap": "0px"
}
}
}
The problem was that the global blockGap value resolved to a unitless 0. The Gallery block uses this value in its column width calculation, where 0px works correctly but 0 makes the CSS declaration invalid.
One additional detail: I did already define a specific blockGap for core/gallery in theme.json:
{
"styles": {
"blocks": {
"core/gallery": {
"spacing": {
"blockGap": "var:preset|spacing|lg"
}
}
}
}
}
However, that value does not appear to be applied because of the known issue described here:
https://github.com/WordPress/gutenberg/issues/60505
So in my case the broken layout was caused by the global blockGap resolving to 0, while the gallery-specific blockGap could not override it due to the existing Gallery block gap specificity issue.
This can probably be closed as a theme configuration issue, but it may still be worth considering whether the Gallery block should handle a unitless 0 more defensively, since 0 is a valid CSS value in many spacing contexts.