Launch Media Library for specific MU site

I have a form on my front end that I'd like to call a media library modal, but I want the library accessed to be a specific MU subsite.

I trued to switch_to_blog around the wp_enqueue_media function, but it is not pulling the media from the targeted site.

Is there a way to achieve this? I don't see a setting the jquery call to initiate the modal but maybe I missed it?

switch_to_blog( 2 );
  wp_enqueue_media();
restore_current_blog();

Topic media-modal media-library multisite Wordpress

Category Web


I asked this in the WP Contributors Slack and was pointed towards this code that allows you to specify the ID of the media library you want to pull from.

https://github.com/humanmade/network-media-library

This doesn't exactly do what I want, it sets a single media library for everysite to use, rather than a specific site on command.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.