Enhanced Responsive Images: Account for Gallery and grid layouts in sizes calculation#2453
Conversation
|
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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #2453 +/- ##
==========================================
+ Coverage 69.33% 69.44% +0.10%
==========================================
Files 90 90
Lines 7749 7779 +30
==========================================
+ Hits 5373 5402 +29
- Misses 2376 2377 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
westonruter
left a comment
There was a problem hiding this comment.
Just a couple quick drive-by suggestions. I haven't reviewed this otherwise, and I'm not really very familiar with how it works.
| * @return array<string, mixed> Modified block context. | ||
| */ | ||
| function auto_sizes_inherit_parent_layout_width( array $context, WP_Block $parent_block ): array { | ||
| $column_count = isset( $parent_block->context['column_count'] ) ? (int) $parent_block->context['column_count'] : 0; |
There was a problem hiding this comment.
| $column_count = isset( $parent_block->context['column_count'] ) ? (int) $parent_block->context['column_count'] : 0; | |
| $column_count = (int) ( $parent_block->context['column_count'] ?? 0 ); |
| isset( $block['attrs']['layout']['type'] ) && | ||
| 'grid' === $block['attrs']['layout']['type'] | ||
| ) { | ||
| $column_count = isset( $block['attrs']['layout']['columnCount'] ) ? (int) $block['attrs']['layout']['columnCount'] : 0; |
There was a problem hiding this comment.
| $column_count = isset( $block['attrs']['layout']['columnCount'] ) ? (int) $block['attrs']['layout']['columnCount'] : 0; | |
| $column_count = (int) ( $block['attrs']['layout']['columnCount'] ?? 0 ); |
| } | ||
|
|
||
| if ( 'core/gallery' === $block['blockName'] ) { | ||
| $column_count = isset( $block['attrs']['columns'] ) ? (int) $block['attrs']['columns'] : 0; |
There was a problem hiding this comment.
| $column_count = isset( $block['attrs']['columns'] ) ? (int) $block['attrs']['columns'] : 0; | |
| $column_count = (int) ( $block['attrs']['columns'] ?? 0 ); |
Summary
Addresses #2449
Updates Enhanced Responsive Images so Gallery blocks and grid-style Group layouts propagate equal-width container constraints to child images for more accurate
sizesattributes.Technical Notes
Props: ravikhadka