Gallery block: Add wide align unit tests#2577
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fix/2449-equal-column #2577 +/- ##
=========================================================
+ Coverage 70.48% 70.50% +0.01%
=========================================================
Files 91 91
Lines 7877 7882 +5
=========================================================
+ Hits 5552 5557 +5
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:
|
| /* | ||
| * When the wide alignment for the gallery, the child image blocks should also use the | ||
| * wide alignment if chile image block didn't set the alignment. | ||
| */ | ||
| $is_parent_gallery = $block->context['is_parent_aligned'] ?? false; | ||
| if ( $is_parent_gallery && '' === $alignment ) { | ||
| $alignment = $max_alignment; | ||
| } |
There was a problem hiding this comment.
The Gallery wide alignment should use the Gallery block's alignment rather than the individual child image alignment when the Gallery block is set to wide.
This change fixes that issue.
There was a problem hiding this comment.
Pull request overview
This PR extends the auto-sizes plugin’s Gallery handling by ensuring Gallery-wide alignment (specifically wide) is reflected in the sizes calculation for child core/image blocks, and it adds PHPUnit coverage to lock in the expected sizes output for wide-aligned galleries.
Changes:
- Add a new render-context flag intended to let Gallery alignment influence child Image blocks’ alignment during
sizescalculation. - Extend Gallery-related test data providers with
widealignment scenarios (automatic columns + explicit columns). - Update
core/imageblock context usage to include the new context key.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| plugins/auto-sizes/includes/improve-calculate-sizes.php | Adds context-based logic to inherit Gallery alignment for child Image blocks and registers a new context key for core/image. |
| plugins/auto-sizes/tests/test-improve-calculate-sizes.php | Adds unit test cases validating sizes output for wide-aligned Gallery block layouts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // If the gallery is aligned, we can assume that the child images are also aligned. | ||
| $context['is_parent_aligned'] = true; |
|
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. |
Summary
Part of #2449
This PR add unit test for
widealignment for gallery block.Use of AI Tools
N/A