From 0eedfedb849b6214c0ac42361074f24c7d3e1555 Mon Sep 17 00:00:00 2001 From: robertgray-topflight Date: Thu, 15 Oct 2026 13:00:54 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Fix=20undefined=20array=20key=20=E2=80=9Cid?= =?UTF-8?q?=E2=80=9D=20warning=20in=20filter=5Fimage=5Fblock=5Frender=5Fbl?= =?UTF-8?q?ock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit filter_image_block_render_block reads $block[‘attrs’][‘id’] whenever a core/image block has overwrite_transformations set. If the block has no id attribute, for example an image block that points at a URL rather than a media library image, PHP logs “Undefined array key id” on every render. This adds a check that the id is not empty before the str_replace runs. Blocks with an id behave as before. QA notes Add a core/image block that uses an external image URL and has overwrite_transformations set in its attributes, and view the page on PHP 8.2 or later with WP_DEBUG on. Before the change, the warning appears in the log for class-filter.php line 733. After the change, it does not. Confirm an image block from the media library with overwrite transformations still gets the cld-overwrite class. --- php/media/class-filter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/media/class-filter.php b/php/media/class-filter.php index 8fe23347b..3a30aee35 100644 --- a/php/media/class-filter.php +++ b/php/media/class-filter.php @@ -729,7 +729,7 @@ public function catch_media_templates_maybe() { * @return string */ public function filter_image_block_render_block( $block_content, array $block ) { - if ( 'core/image' === $block['blockName'] && ! empty( $block['attrs']['overwrite_transformations'] ) ) { + if ( 'core/image' === $block['blockName'] && ! empty( $block['attrs']['overwrite_transformations'] ) && ! empty( $block['attrs']['id'] )) { $block_content = str_replace( 'wp-image-' . $block['attrs']['id'], 'wp-image-' . $block['attrs']['id'] . ' cld-overwrite', $block_content ); } From 2d22cd089def25e9cf2a3a3a5ff4997e5954b525 Mon Sep 17 00:00:00 2001 From: Gabriel de Tassigny Date: Tue, 20 Oct 2026 15:24:16 +0200 Subject: [PATCH 2/2] Fix missing space before closing parenthesis --- php/media/class-filter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/media/class-filter.php b/php/media/class-filter.php index 3a30aee35..dd2876d94 100644 --- a/php/media/class-filter.php +++ b/php/media/class-filter.php @@ -729,7 +729,7 @@ public function catch_media_templates_maybe() { * @return string */ public function filter_image_block_render_block( $block_content, array $block ) { - if ( 'core/image' === $block['blockName'] && ! empty( $block['attrs']['overwrite_transformations'] ) && ! empty( $block['attrs']['id'] )) { + if ( 'core/image' === $block['blockName'] && ! empty( $block['attrs']['overwrite_transformations'] ) && ! empty( $block['attrs']['id'] ) ) { $block_content = str_replace( 'wp-image-' . $block['attrs']['id'], 'wp-image-' . $block['attrs']['id'] . ' cld-overwrite', $block_content ); }