How to make “Upload files”selected by default in Insert Media?

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 }

How does WP media uploader create the 3 different sized images, and how can I duplicate it

Hi @jaredwilli: Dude! Valiant effort, and nice work. All-in-all it could be a great addition to WordPress. You were so close, but you had somewhere between 5 and 10 little failed assumptions or code that looks like you started it but didn’t get back to it because it wasn’t working. I reworked your function only … Read more

How to Require a Minimum Image Dimension for Uploading?

Add this code to your theme’s functions.php file, and it will limit minimum image dimentions add_filter(‘wp_handle_upload_prefilter’,’tc_handle_upload_prefilter’); function tc_handle_upload_prefilter($file) { $img=getimagesize($file[‘tmp_name’]); $minimum = array(‘width’ => ‘640’, ‘height’ => ‘480’); $width= $img[0]; $height =$img[1]; if ($width < $minimum[‘width’] ) return array(“error”=>”Image dimensions are too small. Minimum width is {$minimum[‘width’]}px. Uploaded image width is $width px”); elseif ($height … Read more

How to add new tab to media upload manager with custom set of images?

This is an old thread but for me still as still as relevant. I have been fiddling and has come up with this code for adding a media tab here, maybe someone want to continue for how the handle content for the tab? 🙂 add_action(‘admin_enqueue_scripts’, function(){ wp_enqueue_script( ‘my-media-tab’, plugin_dir_url( __FILE__ ) . ‘/js/mytab.js’, array( ‘jquery’ … Read more

Limit image upload to one and disable audio, video and other document file types to upload

I was about to give up thinking that it wasn’t possible or at least easy and then I stumbled onto the wp_handle_upload_prefilter filter which gives you exactly what you asked for! Here’s the code: add_filter(‘wp_handle_upload_prefilter’, ‘yoursite_wp_handle_upload_prefilter’); function yoursite_wp_handle_upload_prefilter($file) { // This bit is for the flash uploader if ($file[‘type’]==’application/octet-stream’ && isset($file[‘tmp_name’])) { $file_size = getimagesize($file[‘tmp_name’]); … Read more