Native Inserter: Add support for inserting existing site media#221
Merged
Native Inserter: Add support for inserting existing site media#221
Conversation
kean
commented
Nov 7, 2025
| * @param {Array} mediaArray Array of media objects without IDs | ||
| * @return {Promise<boolean>} True if insertion succeeded | ||
| */ | ||
| const insertMediaWithoutIds = async ( mediaArray ) => { |
Contributor
Author
There was a problem hiding this comment.
This code should be unchanged. I'm not sure why git doesn't recognize these as moved lines. I did run a smoke test.
8df28fd to
03850b3
Compare
Member
|
Rebased the branch atop |
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?
When user selects existing site media in the new inserter, it will now be inserted without re-uploading it.
Why?
Matches how GBM and web works.
How?
I'm not completely happy with the implementation, but at least I found getBlockAndPreviewFromMedia in the media-tab.js. Unfortunately, it only deals with individual images and doesn't support galleries.
Alternative considered: remove the custom code that creates
core/galleryand instead usegetBlockAndPreviewFromMediaand insert selected media as individualcore/imageblocks. This way, the user can decide later whether to put them in a gallery. I don't know what the ideal UX is, but the current one poses some technical challenges. It might also not be what everyone wants.Testing Instructions