Trigger refresh for new media manager in 3.5

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

if(wp.media.frame.content.get()!==null){
   wp.media.frame.content.get().collection.props.set({ignore: (+ new Date())});
   wp.media.frame.content.get().options.selection.reset();
}else{
   wp.media.frame.library.props.set({ignore: (+ new Date())});
}

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

Cheers!

Leave a Comment