Skip to content

Instantly share code, notes, and snippets.

Created May 16, 2013 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5588893 to your computer and use it in GitHub Desktop.
Save anonymous/5588893 to your computer and use it in GitHub Desktop.
jQuery(function($) {
var called = 0;
$('#wpcontent').ajaxStop(function() {
if ( 0 == called ) {
$('[value="uploaded"]').attr( 'selected', true );
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');
}
@fishnyc22
Copy link

Sorry line 5 is missing the end that triggers the change so dragging is re-enabled.
$('[value="uploaded"]').attr( 'selected', true ).parent().trigger('change');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment