How to prevent WordPress from creating thumbnails

WordPress has this great feature to create thumbnails for every media (image) you upload.

This is great as long as you use those thumbnails in your theme. However if you don't those extra images will start using up your space. Imagine 3000 uploads with its own set of thumbnails (x3)... well, you do the math.

Some blog posts will recommend you to set the size of the thumbnails (from Settings > Media) to 0. At the time of the writing (WordPress 3.9) the size 0 trick doesn't work.

You can turn the thumbnails off by pasting this snippet in your theme's functions.php file.

function thumbnail_override($sizes){
    unset( $sizes['thumbnail']);
    unset( $sizes['medium']);
    unset( $sizes['large']);

    return $sizes;
add_filter('intermediate_image_sizes_advanced', 'thumbnail_override' );

Overriding custom size thumbnails

If you're using a Child Theme (and you should) you might want to also remove custom sizes set from the parent theme.

Here's an example to remove TwentyTwelve custom thumbnail size:

function thumbnail_override($sizes){

    unset( $sizes['post-thumbnail']);
    return $sizes;
add_filter('intermediate_image_sizes_advanced', 'thumbnail_override', 11 )

As you can see we've done two things here.

  1. Delay the filter by passing 11 as a parameter.
  2. Unsetting the custom size.

About Ricard Torres

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

@ricard_dev @ricard_dev

📝 Blog 🎙 Podcast

Leave a Reply

Add <code> Some Code </code> by using this tags.