Image Block: Don't render if there is no URL set#45220
Merged
Merged
Conversation
Mamaduka
reviewed
Mar 22, 2023
cf52578 to
a7ea505
Compare
Contributor
Author
|
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
|
Contributor
Author
|
@Mamaduka |
Member
|
No worries 😉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
srcattribute, 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