Removing default media image sizes in WordPress

WordPress Remove default media image sizes

After uploading any image to WordPress by default it generate 3 default size of the image

  • Thumbnail
  • Medium Size
  • Large Size
Stop any user to use this  images sizes on your current theme use this following code in your functions.php inside theme folder Remove these using WordPress action intermediate_image_sizes_advanced then unset the thumbnail, medium and large sizes, it means there only left full image size.  
 /**
 * Removes the default wordpress image styles
 * this prevents wordpress to generate other size of image for uploaded image
 *
 * Hooked to intermediate_image_sizes_advanced filter
 * See wp_generate_attachment_metadata( $attachment_id, $file ) in wp-admin/includes/image.php
 *
 * @param $sizes, array of default and added image sizes
 * @return $sizes, modified array of image sizes
 * @author Pawan Kumar http://www.w3-learn.com
 */
function w3learn_filter_image_sizes( $sizes) {
	unset( $sizes['thumbnail']);
	unset( $sizes['medium']);
	unset( $sizes['large']);
	return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'w3learn_filter_image_sizes');