The new media library is awesome but its a bit inefficient. When the page loads, it puts ALL MEDIA ITEMS as the default view. Which causes the page to load a LOT of images. I'd like it to default to "Uploaded to this post".

I've tried other solutions, such as changing the default selection Change the default-view of Media Library in 3.5?

But this is done via JS and when there's a lot of images on the page, it first starts loading the "ALL MEDIA ITEMS" tab and then switches tabs to "Uploaded to this post" so I think the better way to do this would be to reorder the select box so that "Uploaded to this post" is first and the default.

I'm not sure how to go about doing that. Or if its even possible with filters. Would love some feedback from the experts. Thanks!


I was able to answer this via help from a great plugin editor.

This solution doesn't reorder the select box but instead forces it to only load the "Uploaded to this Post" media by default. I used some of the JS from this post to get the select box to change.

I had some help from the great Sewpafly who develops Post Thumbnail Editor Plugin. he shared a great piece of JS that prevents the load of All Media Items and forces it to load only images Uploaded to this Post by default.


jQuery(function($) {
    var called = 0;
    $('#wpcontent').ajaxStop(function() {
        if ( 0 == called ) {
            $('[value="uploaded"]').attr( 'selected', true ).parent().trigger('change');
            called = 1;
  var oldPost = wp.media.view.MediaFrame.Post;
    wp.media.view.MediaFrame.Post = oldPost.extend({
        initialize: function() {
            oldPost.prototype.initialize.apply( this, arguments );
            this.states.get('insert').get('library').props.set('uploadedTo', wp.media.view.settings.post.id);


add_action('admin_enqueue_scripts', 'add_admin_js');
function add_admin_js(){
  wp_enqueue_script('admin_js', get_bloginfo( 'template_directory' ) . '/javascripts/admin.js'); 

As a Gist

I dropped that into a JS file and called it in functions.php with the admin_enqueue_scripts.

Works brilliantly. Hopefully the fine wordpress folks fix this in a upcoming update, but for now Sewpafly has the best solution I've found. Thanks again buddy. Hope this helps some other fine folks out there.

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