Gallery Block: Fix equal column gallery image sizes#2534
Gallery Block: Fix equal column gallery image sizes#2534mukeshpanchal27 wants to merge 43 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feature/2449-gallery-block #2534 +/- ##
==============================================================
+ Coverage 70.38% 70.50% +0.12%
==============================================================
Files 91 91
Lines 7850 7882 +32
==============================================================
+ Hits 5525 5557 +32
Misses 2325 2325
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@westonruter I'd appreciate any initial feedback you can provide on the PR when you have a chance to take a look. |
|
pr makes sense to me, it would be good to add some tests that demonstrate what it achieves. |
|
@mukeshpanchal27 How does this handle the responsive layout? If I add a Gallery with three columns I have this on desktop: But on mobile it becomes 2 columns, and the third image is twice as wide as the first two: There would seem to need to be some logic add this breakpoint in |
|
@westonruter In 46bfea1 i set two column layout for mobile explicitly. In follow-up PR will fix issue for different columns. |
| } | ||
|
|
||
| if ( 'core/gallery' === $block['blockName'] ) { | ||
| if ( wp_is_mobile() ) { |
There was a problem hiding this comment.
We can't rely on wp_is_mobile(), unfortunately. Page caching may not vary responses by device form factor. We'll need a solution that serves the same markup to all devices (the promise of responsive design).
There was a problem hiding this comment.
Can we tackle that in a follow-up PR?
On mobile/responsive layouts with screen widths below 600px, it currently becomes a two-column layout. Since that appears to be a separate issue, I think it would be better to address it in a dedicated follow-up PR.
There was a problem hiding this comment.
I don't think we can tackle in a follow-up, because this is a fundamental design decision or how this feature works. If we can't implement it using responsive design tools, then it won't be viable to ship.
There was a problem hiding this comment.
Yes. Currently, I'm pushing all PRs to the feature/2449-gallery-block feature branch, where all related changes are being gathered.
Once all issues are resolved, we'll open a final PR to merge into trunk. So the release will not be published until all identified issues have been addressed.
|
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. |
…formance into fix/2449-different-columns
There was a problem hiding this comment.
Review of tests from Claude Opus 4.8:
The test name and data-provider name are misleading, and the primary feature is untested.
test_gallery_block_with_explicitly_columns_set/data_gallery_block_with_explicitly_columns_setclaim to test explicit columns, butget_gallery_block_markup()never sets acolumnsattribute — it only setslinkToandalign. So every case exercises the fallback branch (line 370–371, inner-block count capped at 3), and the explicit-columnsbranch (lines 361–362) — the actual headline feature — has zero coverage.- A regression there would go unnoticed. The most valuable missing case: a gallery with
columnsset to a value that differs from the image count, e.g.columns=2with 6 images should yield310px, andcolumns=4should exercise a value above the fallback cap of 3. Please add explicit-columnscases (and rename the test to match what it actually asserts, or split into two tests). - The
$ancestor_block_alignment/$image_block_alignmentparameters are threaded through but only ever''. Either drop them or add wide/full alignment cases (galleries can be aligned, and alignment interacts withcontainer_relative_width).
Recommendation: Approve after addressing the test gap — add explicit-columns cases (including a value above the fallback cap and one differing from image count) and rename the misleading test. The redundant guards and style nit are optional cleanups.
There was a problem hiding this comment.
I updated the test and data-provider name.
The $ancestor_block_alignment / $image_block_alignment parameters are threaded through but only ever ''. Either drop them or add wide/full alignment cases (galleries can be aligned, and alignment interacts with container_relative_width).
I will add tests in follow-up PR. As it needs some adjustments.
Oh, this is what #2543 is for? |
Co-authored-by: Weston Ruter <westonruter@git.wordpress.org>
Fix different column gallery image sizes
Gallery block: Add `wide` align unit tests



Summary
Part of #2449
Relevant Technical Choices
Ensure that the number of images added matches the Gallery block's configured column count.
How to Test
3.3.Before
After
In follow-up PR will fix the sizes for other column settings.
Use of AI Tools
N/A