There were two minor mistakes in my previous answer:
- I forgot to trigger the
change
event for the parent. - I called the function on every AJAX call, making other selections impossible.
Here is the fixed code:
<?php
/**
* 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()
{
?>
<script>
jQuery(function($) {
var called = 0;
$('#wpcontent').ajaxStop(function() {
if ( 0 == called ) {
$('[value="uploaded"]').attr( 'selected', true ).parent().trigger('change');
called = 1;
}
});
});
</script>
<?php
}