Prevent WordPress from generating medium_large 768px size of image uploads?

To remove the medium_large image size you can try to remove it with the intermediate_image_sizes filter: add_filter( ‘intermediate_image_sizes’, function( $sizes ) { return array_filter( $sizes, function( $val ) { return ‘medium_large’ !== $val; // Filter out ‘medium_large’ } ); } ); Not sure if you’re trying to remove all the intermediate sizes, but then you … Read more

Programmatically get images by URL and save in uploads folder

There’s actually a great function that will do all three of those things for you: media_sideload_image( $url, $post_id, $description ); The first argument is the remote url of the image you want to download. The second argument is the post id of the post to which you want to attach the image. The third argument … Read more

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

Creating an Image-Centric Custom Post Type?

goldenapple’s initial answer gave me the jumpstart I needed to finish this up. functions.php Here is the complete code I’m using to add a new post type “header-image” and modify other admin screens accordingly: /** * Register the Header Image custom post type. */ function sixohthree_init() { $labels = array( ‘name’ => ‘Header Images’, ‘singular_name’ … Read more

How to disable WordPress from creating thumbnails?

To built on Max Yudin’s answer you should use the intermediate_image_sizes_advanced filter, and not image_size_names_choose. Add to functions.php function add_image_insert_override($sizes){ unset( $sizes[‘thumbnail’]); unset( $sizes[‘medium’]); unset( $sizes[‘large’]); return $sizes; } add_filter(‘intermediate_image_sizes_advanced’, ‘add_image_insert_override’ ); Another easier option I think works is going to your Settings–>Media and setting each box for width and height to 0

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