close
Skip to content

Gallery: Allow gallery to have more columns than total images#68925

Open
dhananjaykuber wants to merge 1 commit intoWordPress:trunkfrom
dhananjaykuber:feat/gallery-block-more-col-than-images
Open

Gallery: Allow gallery to have more columns than total images#68925
dhananjaykuber wants to merge 1 commit intoWordPress:trunkfrom
dhananjaykuber:feat/gallery-block-more-col-than-images

Conversation

@dhananjaykuber
Copy link
Copy Markdown
Contributor

Fixes #55231

What?

This PR modifies the Gallery block to allow setting the number of columns independently from the number of images, removing the current restriction where column count cannot exceed image count.

Why?

Currently, the Gallery block does not allow setting more columns than there are images. This creates inconsistencies in layouts where multiple galleries need to maintain the same column width, particularly when displaying content like candidate photos where equal sizing is important for fairness.

How?

  • Modified the column width calculation in gallery styles to properly account for gaps
  • Removed the UI restriction that prevented setting columns > number of images
  • Fixed flex-grow behavior to prevent images from expanding to fill empty columns
  • Updated width calculations to maintain consistent image sizes across different gallery configurations

Testing Instructions

  1. Create a new post
  2. Insert a Gallery block
  3. Add 2 images to the gallery
  4. Try setting the number of columns to 4
  5. Verify that the 2 images maintain consistent sizes and don't expand to fill empty spaces
  6. Add another gallery below with 4 images and set to 4 columns
  7. Verify that images in both galleries are the same size despite different image counts

Screenshots or screencast

Screenshot 2025-01-28 at 6 21 52 PM

Screenshot 2025-01-28 at 6 22 01 PM

@github-actions
Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhananjaykuber <dhananjaykuber@git.wordpress.org>
Co-authored-by: cbirdsong <cbirdsong@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Gallery Affects the Gallery Block - used to display groups of images labels Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Gallery Affects the Gallery Block - used to display groups of images [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gallery: Allow gallery to have more columns than total images

2 participants