Skip to content

Image block uses esc_attr() wrongly, passing an array #54930

@swissspidy

Description

@swissspidy

Description

Introduced in #3851 / badc344, this causes PHP warnings when using the Image block with Lightbox enabled.

Why?

The block_core_image_render_lightbox() function passes the results of wp_get_global_styles() directly to esc_attr().

wp_get_global_styles() can return an array, but esc_attr() works on strings.

Step-by-step reproduction instructions

  1. Insert image block with lightbox (I was using the 2021 theme)
  2. See warning

Screenshots, screen recording, code snippet

No response

Environment info

WP trunk

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] ImageAffects the Image Block[Feature] Interactivity APIAPI to add frontend interactivity to blocks.[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions