From 1219ab75b0ceff7b0066c9b4abdac0e6e37fc5d5 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 15 Oct 2026 22:16:27 -0700 Subject: [PATCH 1/4] Cast width to string before passing to rtrim() since it may be float --- plugins/auto-sizes/includes/improve-calculate-sizes.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/auto-sizes/includes/improve-calculate-sizes.php b/plugins/auto-sizes/includes/improve-calculate-sizes.php index 027f4d1013..e67f88c2d5 100644 --- a/plugins/auto-sizes/includes/improve-calculate-sizes.php +++ b/plugins/auto-sizes/includes/improve-calculate-sizes.php @@ -366,7 +366,8 @@ function auto_sizes_filter_render_block_context( array $context, array $block, ? if ( count( $found_image_block ) > 0 || count( $found_cover_block ) > 0 ) { // Get column width, if explicitly set. if ( isset( $block['attrs']['width'] ) && '' !== $block['attrs']['width'] ) { - $current_width = floatval( rtrim( $block['attrs']['width'], '%' ) ) / 100; + // Note: In old versions of the Columns block, the percentage width may be a float. So the string cast is required. + $current_width = floatval( rtrim( (string) $block['attrs']['width'], '%' ) ) / 100; } elseif ( isset( $parent_block->context['column_count'] ) && $parent_block->context['column_count'] ) { // Default to equally divided width if not explicitly set. $current_width = 1.0 / $parent_block->context['column_count']; From 36947231d92c6e28cf33ba7f5ecd3c762a2b6855 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 15 Oct 2026 22:27:14 -0700 Subject: [PATCH 2/4] Cast postId block context to int before getting featured image Block context is not type-coerced, and a third-party block can provide `postId` from a raw attribute via `providesContext`. With strict types, a numeric string there would cause a TypeError when passed to `auto_sizes_get_featured_image_attachment_id()`. Co-Authored-By: Claude Opus 5.5 --- plugins/auto-sizes/includes/improve-calculate-sizes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/auto-sizes/includes/improve-calculate-sizes.php b/plugins/auto-sizes/includes/improve-calculate-sizes.php index e67f88c2d5..53cd1d4aa5 100644 --- a/plugins/auto-sizes/includes/improve-calculate-sizes.php +++ b/plugins/auto-sizes/includes/improve-calculate-sizes.php @@ -113,7 +113,7 @@ function auto_sizes_filter_image_tag( $content, array $parsed_block, WP_Block $b * See https://github.com/WordPress/wordpress-develop/blob/3f9c6fce666ed2ea0d56c21f6235c37db3d91392/src/wp-includes/blocks/post-featured-image.php#L65 */ if ( 'core/post-featured-image' === $block->name && isset( $block->context['postId'] ) ) { - $id = auto_sizes_get_featured_image_attachment_id( $block->context['postId'] ); + $id = auto_sizes_get_featured_image_attachment_id( (int) $block->context['postId'] ); } /* @@ -141,7 +141,7 @@ function auto_sizes_filter_image_tag( $content, array $parsed_block, WP_Block $b * See https://github.com/WordPress/wordpress-develop/blob/3f9c6fce666ed2ea0d56c21f6235c37db3d91392/src/wp-includes/blocks/post-featured-image.php#L65 */ if ( 'core/post-featured-image' === $block->name && isset( $block->context['postId'] ) ) { - $id = auto_sizes_get_featured_image_attachment_id( $block->context['postId'] ); + $id = auto_sizes_get_featured_image_attachment_id( (int) $block->context['postId'] ); } $sizes = wp_calculate_image_sizes( From 97c0e56d7b679d641e7d8ce47bb2567eca35fe59 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 15 Oct 2026 22:27:57 -0700 Subject: [PATCH 3/4] Cast align block attribute to string before calculating sizes Block attributes are not type-coerced on the server, so `align` is passed through exactly as stored in the block comment delimiter. With strict types, a non-string value would cause a TypeError when passed to the `string $align` parameter of `auto_sizes_calculate_better_sizes()`. Co-Authored-By: Claude Opus 5.5 --- plugins/auto-sizes/includes/improve-calculate-sizes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/auto-sizes/includes/improve-calculate-sizes.php b/plugins/auto-sizes/includes/improve-calculate-sizes.php index 53cd1d4aa5..79b263f1d9 100644 --- a/plugins/auto-sizes/includes/improve-calculate-sizes.php +++ b/plugins/auto-sizes/includes/improve-calculate-sizes.php @@ -103,7 +103,7 @@ function auto_sizes_filter_image_tag( $content, array $parsed_block, WP_Block $b */ $filter = static function ( $sizes, $size ) use ( $block ) { $id = isset( $block->attributes['id'] ) ? (int) $block->attributes['id'] : 0; - $alignment = $block->attributes['align'] ?? ''; + $alignment = (string) ( $block->attributes['align'] ?? '' ); $width = isset( $block->attributes['width'] ) ? (int) $block->attributes['width'] : 0; $max_alignment = $block->context['max_alignment'] ?? ''; $container_relative_width = $block->context['container_relative_width'] ?? 1.0; From 978459058bde6e86220e618917aeb0a56b9c3fe3 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 15 Oct 2026 22:31:18 -0700 Subject: [PATCH 4/4] Cast container align attribute to string for max alignment context The raw `align` attribute of a container block is copied into the `max_alignment` context, which is later passed to the `string $max_alignment` parameter of `auto_sizes_calculate_better_sizes()`. Block attributes are not type-coerced on the server, so with strict types a non-string value would cause a TypeError. Co-Authored-By: Claude Opus 5.5 --- plugins/auto-sizes/includes/improve-calculate-sizes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/auto-sizes/includes/improve-calculate-sizes.php b/plugins/auto-sizes/includes/improve-calculate-sizes.php index 79b263f1d9..2983a113e1 100644 --- a/plugins/auto-sizes/includes/improve-calculate-sizes.php +++ b/plugins/auto-sizes/includes/improve-calculate-sizes.php @@ -348,7 +348,7 @@ function auto_sizes_filter_render_block_context( array $context, array $block, ? if ( in_array( $block['blockName'], $provider_blocks, true ) ) { // Normalize default alignment values. - $alignment = isset( $block['attrs']['align'] ) && '' !== $block['attrs']['align'] ? $block['attrs']['align'] : 'default'; + $alignment = isset( $block['attrs']['align'] ) && '' !== $block['attrs']['align'] ? (string) $block['attrs']['align'] : 'default'; // Use the defined constant for constraints. $constraints = AUTO_SIZES_CONSTRAINTS;