-
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
Fix: Don't render image when src
attribute is empty
#66004
Conversation
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.
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. |
Co-authored-by: SantosGuillamot <[email protected]> Co-authored-by: gziolo <[email protected]>
I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: a0f74e8 |
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. |
Co-authored-by: SantosGuillamot <[email protected]> Co-authored-by: gziolo <[email protected]>
Co-authored-by: SantosGuillamot <[email protected]> Co-authored-by: gziolo <[email protected]>
What?
In this old pull request, a check was introduced to not render the image when the
src
attribute 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
trunk
Following 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