Upload external media: Ensure notice only fires once#77218
Conversation
|
Size Change: +13 B (0%) Total Size: 7.74 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in 330fc18. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24229285166
|
|
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 the quick review! 🙇 |



What?
Ensure "Image uploaded" notice, fired by the "Upload to Media Library" toolbar button, only fires once.
Why?
Found while testing #77178. With client-side media processing active (i.e. running GB locally with Chrome browser), the notice fires too many times (i.e. once when each sub-size image is generated), whereas we want it to only fire once.
How?
Add a variable within the
uploadExternalfunction to track whether we've fired the notice yet.This is a fairly simple and naive fix. Another way to do it would be to add an
onSuccesshandler for the client-side media uploading path, and inonFileChangeadd a check to see if client-side media handling is active, and if not fire in there instead. IMO that would be a little more complex than this change, which is a little tidier.Testing Instructions
In a local environment (i.e. not Playground) where client-side media processing is active, add the following in the code view of a post. It's an externally linked image that will give you access to the "Upload to Media Library" button:
Switch back to the visual view and click the "Upload to Media Library" button:
Screenshots or screencast
Before
After
2026-04-10.15.44.39.mp4
Use of AI Tools
Claude Code (Opus 4.6)