gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Columns not working

Open JelleTempelman opened this issue 5 months ago • 2 comments

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

  1. Create a new post or page.
  2. Insert a Gallery block.
  3. Add at least two images to the Gallery block.
  4. Select the Gallery block.
  5. In the block sidebar, change the number of columns to 2 or more.
  6. Observe the layout in the editor.
  7. Publish or preview the post/page.
  8. 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

JelleTempelman avatar Jun 16 '26 11:06 JelleTempelman

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.

Editor view: Gallery block with 3 images 
and columns set to 3 — all images appear in a single row

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.

Frontend view: Published page showing 
3 Gallery images correctly displayed in 3 columns

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.

vedant-ere avatar Jun 16 '26 14:06 vedant-ere

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.

JelleTempelman avatar Jun 16 '26 15:06 JelleTempelman