-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Image Block: Don't render if there is no URL set #45220
Conversation
cf52578
to
a7ea505
Compare
Thank you for the review, @Mamaduka! I rebased with the latest trunk and adjusted the code. |
Flaky tests detected in a7ea505. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4486800784
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @t-hamano! The changes work as expected.
@Mamaduka |
No worries 😉 |
Fix #44639
What?
This PR disables rendering on the front end when no URL is set in the image block.
Why?
When the image block doesn't have a URL, the front end outputs HTML like this:
According to MDN, the img element must have
src
attribute, so I believe this is incorrect markup.How?
This PR uses the new HTML Tag Processor API introduced in #42485 and changed to output nothing if the src attribute is empty. This rule is similar to the one that outputs nothing if the image is empty in the following block:
Also, a refactoring using this API in the core block in general is proposed by #43178. So this PR may need to be updated after #43178 is merged to prevent conflicts.
Testing Instructions