Client-side media processing: Try plumbing invalidation to the block-editor's mediaUpload onSuccess callback#76173
Conversation
|
Size Change: -18 B (0%) Total Size: 6.87 MB
ℹ️ View Unchanged
|
|
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. |
Agreed, that was part of my thinking in making this a private key, as ideally we'd remove it and (somehow) make the invalidation internal to |
…editor's mediaUpload onSuccess callback
f7c2510 to
7962aa8
Compare
What?
Alternative to #76121 to invalidate media cache once an update has completed for the client-side media processing.
This fixes a bug where if you upload an image to an image block to the post editor on trunk, the block editor thinks it's an external image until you reload the editor.
The approach in this PR is to plumb an
onSuccesscallback down to the block-editor so that it can pass anonSuccesscallback to theupload-mediapackage'saddItemscalls. This ensures that when an item (and all its sub-sizes) has completely finished uploading, we can fire theonSuccesscallback at the right time.Why?
The approach in #76121 is a little indirect as it's watching the store to see if items disappear from the queue rather than actually firing directly on
onSuccess.The reasoning as to why we need to do this plumbing is fairly complex:
editorpackage can know aboutcore-datamedia-utils'mediaUploaddoesn't have a proper concept ofonSuccessupload-mediapackage to be able to callonSuccesswith the invalidation code at just the right timeI'm happy to expand on this further, but it's unfortunately quite challenging to describe!
How?
editorpackage to invalidateResolution for media entity recordsonSuccessis called, it fires off the invalidationTesting Instructions
Follow the instructions in #76121
Screenshots or screencast
It should work just the same as #76121. That is, after uploading an image with the client-side media processing active, you should be able to go to the settings tab and select a different image size.