Fix: Don't render image when src attribute is empty#66004
Merged
Conversation
gziolo
approved these changes
Oct 10, 2024
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
gutenbergplugin
pushed a commit
that referenced
this pull request
Oct 10, 2024
Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org> Co-authored-by: gziolo <gziolo@git.wordpress.org>
|
I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: a0f74e8 |
This was referenced Oct 10, 2024
Contributor
|
Thanks for the fix! I can't remember why I used a null check instead of an empty check, but I think the approach in this PR is the best. |
ciampo
pushed a commit
that referenced
this pull request
Oct 14, 2024
Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org> Co-authored-by: gziolo <gziolo@git.wordpress.org>
karthick-murugan
pushed a commit
to karthick-murugan/gutenberg
that referenced
this pull request
Nov 13, 2024
Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org> Co-authored-by: gziolo <gziolo@git.wordpress.org>
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.




What?
In this old pull request, a check was introduced to not render the image when the
srcattribute is not defined. Following the same logic, I believe the image shouldn't render when the attribute is an empty string. This could be the case when that attribute is connected to an empty custom field through block bindings, for example.Why?
When the image src is an empty string, this is the resulting HTML in
trunkFollowing the same reasoning of the original PR: "According to MDN, the img element must have src attribute, so I believe this is incorrect markup."
For that reason, I think it is better to not render the image.
How?
I'm just changing the conditional to not render the image when the attribute is falsy, not only null.
Testing Instructions