WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to figure out how it's possible to 'refresh' the media library in the new media dialogue in 3.5. I'm adding images from an external image library to the WordPress library (via a tab/iFrame combo in the media dialogue) which works ok, but I have to close and reopen the dialogue in order to show the newly added images (which have successfully been aded to the library).

I know there are wp.media.editor.open() and wp.media.editor.close() methods, but I can't quite manage to find a sort() or refresh() (or whatever) in the source. Truth be told, the source code is pretty intense reading and console.log doesn't seemingly help much with backbone.js. Any ideas?

share|improve this question
One more Question to the gallery "New Media Manager: The Great Unknown". By the rhythm it goes, I expect full documentation and hooks around WP 3.7... All the upvotes indicate a hungry community. – brasofilo Feb 12 '13 at 4:50
Instead of refresh() function , we can use combination of wp.media.editor.close() and wp.media.editor.open() function to achieve the desired output. – Vinod Dalvi Feb 18 '13 at 10:01
In the featured-image-picker for example, there is a switch in wp-includes/js/media-views.js line 3644 for whether or not media library has loaded. It would seem to be referencing wp.media.featuredImage.frame().views.get('.media-frame-content')[0].views.get("‌​")[3].collection.length but setting that length to 0 doesn't do anything. – NoBugs Oct 9 '15 at 4:50

Took me a couple days but I finally dug my way through things enough to figure this out:

wp.media.editor.get(wpActiveEditor).views._views[".media-frame-content"][0].views._views[""][1].collection.props.set({ignore:(+(new Date()))})

Seems like there must be an easier way but that works for me in the meantime!

share|improve this answer
seems so intuitive :) nevertheless, this works!! THANK YOU!!! – Andrej Jun 24 '13 at 18:58
just found a "more official" way to do it: wp.media.frame.content.get('gallery').collection.props.set({ignore: (+ new Date())});, in this case i'm refreshing the gallery tab. – Jermim bilal Apr 21 '14 at 17:31
While both commands do trigger a refresh, afterwards you can no longer add images in the modal :( need another solution to this – Benjamin Jun 21 '14 at 13:22

The correct way of refreshing the content of the frame, as found in the WP core, is as below:

   wp.media.frame.content.get().collection.props.set({ignore: (+ new Date())});
   wp.media.frame.library.props.set({ignore: (+ new Date())});

You should always check of the content is available, else refresh the library.


share|improve this answer
Where is this in WP core? – NoBugs Oct 8 '15 at 16:04
Are you sure this is still correct? It seems wp.media.featuredImage.frame().options.selection.reset exists but there is no wp.media.featuredImage.frame().collection for example. – NoBugs Oct 9 '15 at 3:36

is it what you are looking for

share|improve this answer
Please explain why that could solve the problem. – toscho Feb 26 '13 at 12:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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