I am frustrated having to click on the "Upload Files" constantly instead of the first choice being Upload Files in posts editor....How can i make “Upload files” selected by default instead of "Media library"?
2 Answers
Add this to your functions.php, or preferably a functionality plugin.
add_action( 'admin_footer-post-new.php', 'media_manager_default' );
add_action( 'admin_footer-post.php', 'media_manager_default' );
function media_manager_default() {
?>
<script type="text/javascript">
jQuery(document).ready(function($){
wp.media.controller.Library.prototype.defaults.contentUserSetting=false;
});
</script>
<?php
}
-
6Damn dude how deep into core did you have to go to pull that one out? Apr 19, 2013 at 23:54
-
Changed it to: jQuery(".media-router a:first-child").addClass("active"); jQuery(".media-router a:last-child").remveClass("active"); And it worked (posting here because of request) Jun 13, 2016 at 9:14
If some one it's still looking for a solution, this solution worked for me for all upload images in any post types and on featured images as well:
function upload_media_manager_by_default() {
if ( did_action( 'wp_enqueue_media' ) ) {
?>
<script type="text/javascript">
jQuery( document ).ready( function ( $ ) {
wp.media.controller.Library.prototype.defaults.contentUserSetting = false;
wp.media.controller.FeaturedImage.prototype.defaults.contentUserSetting = false;
});
</script>
<?php
}
}
add_action( 'admin_footer', 'upload_media_manager_by_default' );