I am writing an extension that will load images from third party sources and embed that image in WP media library.
I cannot figure out how to manage wp.media to load such images.
How it will work. When the user opens the media library, he will have an additional download button from BrandFolder By clicking on the button, we will get its catalog of images by api. Having selected the necessary picture, we can get its url, using php we can download this picture and create a post of the attachment type.
And now we have the attachment ID, but how do we now insert it into the media library without reloading the page and then switch the tab to the Media Library tab?
I think such a flow would be suitable
- Choose a picture
- Load the picture and create a post type attachment
- After that, at the front, using wp.media, switch the active tab to Media Library
- Reload the content of the Media library tab
But how 3 and 4 points I can’t figure out, can someone help me with this?