Skip to content

Commit 266e457

Browse files
Initial review feedback improvements
Co-authored-by: Weston Ruter <[email protected]>
1 parent d3a60d0 commit 266e457

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

plugins/auto-sizes/includes/improve-calculate-sizes.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function auto_sizes_filter_image_tag( $content, array $parsed_block, WP_Block $b
8585
$id = $block->attributes['id'] ?? 0;
8686
$alignment = $block->attributes['align'] ?? '';
8787
$width = $block->attributes['width'] ?? '';
88-
$max_alignment = $block->context['max_alignment'];
88+
$max_alignment = $block->context['max_alignment'] ?? '';
8989

9090
/*
9191
* Update width for cover block.
@@ -132,11 +132,11 @@ function auto_sizes_filter_image_tag( $content, array $parsed_block, WP_Block $b
132132
*
133133
* @since n.e.x.t
134134
*
135-
* @param int $id The image id.
136-
* @param string|int[] $size The image size data.
137-
* @param string $align The image alignment.
138-
* @param string $resize_width Resize image width.
139-
* @param string $max_alignment The maximum usable layout alignment.
135+
* @param int $id The image attachment post ID.
136+
* @param string|array{int, int} $size Image size name or array of width and height.
137+
* @param string $align The image alignment.
138+
* @param string $resize_width Resize image width.
139+
* @param string $max_alignment The maximum usable layout alignment.
140140
* @return string|false An improved sizes attribute or false if a better size cannot be calculated.
141141
*/
142142
function auto_sizes_calculate_better_sizes( int $id, $size, string $align, string $resize_width, string $max_alignment ) {
@@ -166,7 +166,7 @@ function auto_sizes_calculate_better_sizes( int $id, $size, string $align, strin
166166
}
167167

168168
// Normalize default alignment values.
169-
$align = (bool) $align ? $align : 'default';
169+
$align = '' !== $align ? $align : 'default';
170170

171171
/*
172172
* Map alignment values to a weighting value so they can be compared.
@@ -238,9 +238,9 @@ function auto_sizes_get_layout_width( string $alignment ): string {
238238
*
239239
* @since n.e.x.t
240240
*
241-
* @param array<string> $uses_context Array of registered uses context for a block type.
241+
* @param string[] $uses_context Array of registered uses context for a block type.
242242
* @param WP_Block_Type $block_type The full block type object.
243-
* @return array<string> The filtered context keys used by the block type.
243+
* @return string[] The filtered context keys used by the block type.
244244
*/
245245
function auto_sizes_filter_uses_context( array $uses_context, WP_Block_Type $block_type ): array {
246246
// The list of blocks that can consume outer layout context.

0 commit comments

Comments
 (0)