Change the default-view of Media Library in 3.5?

When inserting media into a post, is there a way to change the default-view of the Media-Library from “All media items” to “Uploaded to this post”?

borrowed Screenshot

There is another thread where this question was extracted from:
How to manage attachment relationships


There were two minor mistakes in my previous answer:

  1. I forgot to trigger the change event for the parent.
  2. I called the function on every AJAX call, making other selections impossible.

Here is the fixed code:

 * Plugin Name: Pre-select post specific attachments

add_action( 'admin_footer-post-new.php', 'wpse_76048_script' );
add_action( 'admin_footer-post.php', 'wpse_76048_script' );

function wpse_76048_script()
jQuery(function($) {
    var called = 0;
    $('#wpcontent').ajaxStop(function() {
        if ( 0 == called ) {
            $('[value="uploaded"]').attr( 'selected', true ).parent().trigger('change');
            called = 1;

Leave a Comment