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?

  • 3
    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, 2013 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. Feb 18, 2013 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, 2015 at 4:50

4 Answers 4


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.


  • Where is this in WP core?
    – NoBugs
    Oct 8, 2015 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, 2015 at 3:36

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!

  • 1
    seems so intuitive :) nevertheless, this works!! THANK YOU!!!
    – Andrej
    Jun 24, 2013 at 18:58
  • 3
    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. Apr 21, 2014 at 17:31
  • 2
    While both commands do trigger a refresh, afterwards you can no longer add images in the modal :( need another solution to this Jun 21, 2014 at 13:22
  • This is still a far from ideal solution, but it's worth noting the media-frame-content key has changed from 1 to 2: wp.media.editor.get(wpActiveEditor).views._views[".media-frame-content"][0].views._views[""][2].collection.props.set({ignore:(+(new Date()))})
    – Ian
    Sep 23, 2016 at 12:35
  • For the above reason you're better off using the more generic version posted elsewhere in this question: wp.media.frame.content.get().collection.props.set({ignore: (+ new Date())});
    – Ian
    Sep 23, 2016 at 12:52

2019 update. I found a better solution that doesnt break the uploader:

wp.media.frame.on('open', function() {
    if (wp.media.frame.content.get() !== null) {          
        // this forces a refresh of the content

        // optional: reset selection
}, this);

is it what you are looking for

  • 1
    Please explain why that could solve the problem.
    – fuxia
    Feb 26, 2013 at 12:25

Your Answer

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

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