Skip to content

Fix undefined array key “id” warning in filter_image_block_render_block - #1321

Merged
gabrielcld2 merged 2 commits into
cloudinary:developfrom
robertgray-topflight:patch-1
Oct 20, 2026
Merged

gabrielcld2 merged 2 commits into
cloudinary:developfrom
robertgray-topflight:patch-1

Conversation

@robertgray-topflight

Copy link
Copy Markdown

Approach

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

  1. Add a core/image block that uses an external image URL and has overwrite_transformations set in its attributes, then view the page on PHP 8.2 or later with WP_DEBUG on.
  2. Before the change, the warning appears in the log for class-filter.php line 733. After the change, it does not.
  3. Confirm an image block from the media library with overwrite transformations still gets the cld-overwrite class.

@gabrielcld2
gabrielcld2 changed the base branch from master to develop October 20, 2026 13:17
robertgray-topflight and others added 2 commits October 20, 2026 15:24
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.
@gabrielcld2

Copy link
Copy Markdown
Collaborator

@robertgray-topflight thank you for your contribution! This will be included in the upcoming release

@gabrielcld2
gabrielcld2 merged commit 6df0508 into cloudinary:develop Oct 20, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants