Block Library: Show fallback label in MediaControl when filename is empty#76888
Conversation
|
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. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @jigangz! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
There was a problem hiding this comment.
Thanks, @jigangz!
While tests are more than welcome for bug fixes, I don't think this simple case needs one.
…mpty When a media URL does not end with a recognizable filename (e.g., server-generated images like `https://api.example.com/.../thumb/`), `getFilename()` returns an empty string. This caused the MediaControl label to render as blank in the inspector panel. Add a fallback to `emptyLabel` when `getFilename()` returns a falsy value, so the control always shows a meaningful label. Fixes WordPress#76882
0ce9ab7 to
def0b1b
Compare
…mpty (#76888) Co-authored-by: jigangz <jigangz@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: Adi-ty <iamadisingh@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
…mpty (#76888) Co-authored-by: jigangz <jigangz@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: Adi-ty <iamadisingh@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
What?
Show a fallback label in
MediaControlwhengetFilename()returns an empty string.Why?
When a media URL does not end with a recognizable filename (e.g., server-generated images like
https://api.openverse.org/v1/images/.../thumb/),getFilename()returns an empty string. This causes theMediaControllabel to render as blank in the inspector panel.How?
Add a fallback to
emptyLabelwhengetFilename()returns a falsy value:This keeps the fix minimal in
MediaControlas suggested by @Adi-ty.Testing Instructions
https://api.openverse.org/v1/images/e945bba3-4817-468f-8740-57d326de5b6d/thumb/)Fixes #76882