Skip to content

Native Inserter: Add support for inserting existing site media#221

Merged
dcalhoun merged 1 commit intotrunkfrom
task/add-direct-media-insertion-no-id
Nov 7, 2025
Merged

Native Inserter: Add support for inserting existing site media#221
dcalhoun merged 1 commit intotrunkfrom
task/add-direct-media-insertion-no-id

Conversation

@kean
Copy link
Contributor

@kean kean commented Nov 7, 2025

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/gallery and instead use getBlockAndPreviewFromMedia and insert selected media as individual core/image blocks. 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

@kean kean changed the title Add support for inserting existing media with IDs Native Inserter: Add support for inserting existing site media Nov 7, 2025
@kean kean requested a review from dcalhoun November 7, 2025 13:22
* @param {Array} mediaArray Array of media objects without IDs
* @return {Promise<boolean>} True if insertion succeeded
*/
const insertMediaWithoutIds = async ( mediaArray ) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should be unchanged. I'm not sure why git doesn't recognize these as moved lines. I did run a smoke test.

Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected. 🚀

@dcalhoun dcalhoun force-pushed the task/add-direct-media-insertion-no-id branch from 8df28fd to 03850b3 Compare November 7, 2025 18:01
@dcalhoun
Copy link
Member

dcalhoun commented Nov 7, 2025

Rebased the branch atop trunk as the changes in 166d1e0 were needed for testing the WordPress-iOS integration.

@dcalhoun dcalhoun enabled auto-merge (squash) November 7, 2025 18:02
@dcalhoun dcalhoun merged commit b34b070 into trunk Nov 7, 2025
11 checks passed
@dcalhoun dcalhoun deleted the task/add-direct-media-insertion-no-id branch November 7, 2025 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants