Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Stop crashing with Lightbox on image blocks without an image. #5461

Closed

Conversation

dmsnell
Copy link
Member

@dmsnell dmsnell commented Oct 11, 2023

Trac ticket: Core-59597

Resolves WordPress/gutenberg#55214

When rendering images with the lightbox "expand on click" function enabled, if an image block is encountered with no image (for example, a block was added but no image was ever selected), then WordPress would create a warning that an "undefined array key 0" was being accessed because the server code assumes an IMG element exists in the block's HTML.

In this patch a check is performed to ensure that an IMG block exists before processing the block. If one isn't, for any reason, the original given HTML for the block is passed through un-modified.

This patch needs to be backported into Gutenberg from where it's sourced but this issue arose during the WordPress 6.4 beta testing and needs to be resolved immediately in Core.

Resolves WordPress/gutenberg#55217

When rendering images with the lightbox "expand on click" function enabled,
if an image block is encountered with no image (for example, a block was
added but no image was ever selected), then WordPress would create a warning
that an "undefined array key 0" was being accessed because the server code
assumes an IMG element exists in the block's HTML.

In this patch a check is performed to ensure that an IMG block exists before
processing the block. If one isn't, for any reason, the original given HTML
for the block is passed through un-modified.

This patch needs to be backported into Gutenberg from where it's sourced
but this issue arose during the WordPress 6.4 beta testing and needs to
be resolved immediately in Core.
@dmsnell dmsnell force-pushed the fix/image-lightbox-without-img branch from 103c67c to 770586a Compare October 11, 2023 13:17
@hellofromtonya
Copy link
Contributor

Hey @dmsnell, is WordPress/gutenberg#55217 the correct link back to the issue in Gutenberg? They seem unrelated.

@dmsnell
Copy link
Member Author

dmsnell commented Oct 11, 2023

thank you @hellofromtonya - correct, that was a mistake. I've updated the description to point to the right issue now, which is 55214 and not 55217

@dmsnell
Copy link
Member Author

dmsnell commented Oct 11, 2023

Closing since this has been incorporated into Gutenberg and will come over in the next package update.

@dmsnell dmsnell closed this Oct 11, 2023
@dmsnell dmsnell deleted the fix/image-lightbox-without-img branch October 11, 2023 19:32
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.

Undefined array key warning (image block)
2 participants