Using the WordPress 3.5 Media Uploader window as a modal popup

You can try the following script: var MEDIAmedia_library: function() { var formfield = null; var wireframe; $(‘body’).on(‘click’, ‘#click-event-selector’,function(e) { e.preventDefault(); if (wireframe) { wireframe.open(); return; } wireframe = wp.media.frames.wireframe = wp.media({ title: ‘Media Library Title’, button: { text: ‘Media Library Button Title’ }, multiple: false }); wireframe.on(‘select’, function() { attachment = wireframe.state().get(‘selection’).first().toJSON(); console.log(attachment); $(‘#input-field-selector’).val(attachment.url); }); … Read more

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!