1

I'm writing a file upload plugin and want to emulate original Wordpress behavior:

  1. user uploads file on "Upload Files" tab
  2. after upload is complete, "Media Library" tab is activated with just uploaded files selected.

Granted I know how to add a third tab, I want after some to switch to "Media Library" tab, if I could select attachments on the tab, that would be awesome too.

I have browsed docs and js code but failed to find anything. Snippet would be great, pointing to a proper article will suffice.

2 Answers 2

1

I found nothing better than:

// switch to attachment browser
wp.media.frame.content.mode('browse');
// refresh attachment collection
wp.media.frame.content.view.views._views[".media-frame-content"][0].views._views[""][1].collection.props.set({ignore:(+(new Date()))});

Feel free to add proper way of doing this.

0

This could help, I can confirm it works in WordPress 6.5:

wp.media.frame.content.get().collection._requery(true);
wp.media.frame.content.get().options.selection.reset();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.