No More Extra Files
In order to eliminate thumbnails and stop creating those extra image sizes, I hooked into the intermediate_image_sizes filter. This is the code I added tofunctions.php:
add_filter( 'intermediate_image_sizes', bavotasan_custom_intermediate_image_sizes, 999 );
function bavotasan_custom_intermediate_image_sizes( $image_sizes ){
// @NOTE Be sure to change 'custom_post_type_slug' to the actual slug of your custom post type
if ( isset( $_REQUEST['post_id'] ) && 'custom_post_type_slug' === get_post_type( $_REQUEST['post_id'] ) )
return array();
return $image_sizes;
}
First I checked if they were uploading to the custom post type, then I returned an empty array instead of the default image sizes. Simple enough.
No Thumbnails Whatsoever
If you want to stop this for all uploaded images, you could simplify the code even more:
add_filter( 'intermediate_image_sizes', bavotasan_custom_intermediate_image_sizes, 999 );
function bavotasan_custom_intermediate_image_sizes( $image_sizes ){
return array();
}
Now you only have to return an empty array. No need to check for a custom post type.
Either one of the functions above will end up saving you a lot of space. If you don’t needs those extra files, eliminate them before they’re created.
If you know of a better solution, feel free to add your thoughts in the comment section below.
Featured image provided by Death to the Stock Photo.