How to Change the default-view of Media Library in WordPress?
Use the below example code theme’s functions.php file to change the default-view of Media Library in WordPress.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?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 } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.