How to Remove Image Sizes in WordPress

In an earlier post about image sizes in WordPress, we had shown you a way to choose which image sizes are available for choosing when you're inserting an image in a post or page. Today, we are posting a more complete solution where you can actually tell WordPress which image sizes it should or should not generated, and then choose which ones are available in the media uploader/image insertion screen.

In an earlier post about image sizes in WordPress, we had shown you a way to choose which image sizes are available for choosing when you’re inserting an image in a post or page.

Today, we are posting a more complete solution where you can actually tell WordPress which image sizes it should or should not generated, and then choose which ones are available in the media uploader/image insertion screen.

Here’s the code you will be needing, place this in your functions.php file:

function wpmayor_filter_image_sizes( $sizes) {

unset( $sizes['medium']);
unset( $sizes['large']);
unset( $sizes['wysija-newsletters-max']);

return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'wpmayor_filter_image_sizes');

function wpmayor_custom_image_sizes($sizes) {
$myimgsizes = array(
"image-in-post" => __( "Image in Post" ),
"full" => __( "Original size" )
);
return $myimgsizes;
}
add_filter('image_size_names_choose', 'wpmayor_custom_image_sizes');

 

As you can see, I am disabling the three sizes WordPress generates by default (thumbnail, medium, large), along with a size generated by a plugin (this could be any custom size you added using add_image_size).

In the second function I then choose which sizes I want available in my image insertion screen, and I can also give them any name I want.

Here’s a screenshot of the end result:

custom image sizes in WordPress

If you enjoyed this post, make sure to subscribe to WP Mayor’s RSS feed.

Jean Galea
Jean Galea
Jean Galea is an investor, entrepreneur, and blogger. He is the founder of WP Mayor, the plugins WP RSS Aggregator and Spotlight, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.

Consider sharing this post so others can find it:

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on telegram
Share on whatsapp
Share on pocket
Share on email

Join thousands of people receiving real-world, genuine evaluations of WordPress products and services just like this one every week.

17 Responses

  1. I would like to add that you better not disable the ‘thumbnail’ size.
    Because if you use the image selector for custom fields in WordPress admin, the original image will be shown if the thumbnail isn’t present.

  2. not work for me at all, when I paste the code into functions.php in theme folder nothing happens, when I do so in WP file, the whole web goes off…

  3. But still Need one major issue , Stop use thumbnail native image
    I want Use cache image thumbnail inserted of native image, its create junk on web-space
    e.g If I upload one product its make 3-6 thumbnail image from original picture.

    How can I use Cache images system e.g. megento, prestashop, opencart with easy one click all cache clear option
    note: use spl folder location for store cache images not wp-content/2015/12/

  4. In case I unset( $sizes[‘wysija-newsletters-max’]), what image does the plugin fall back to when sending automated newsletters?

    I have it set up to send posts of a certain category immediately as newsletters and it attaches the post featured image in dimensions 600×9999, which looks awful.

    How can I change that?

Leave a Reply

Your email address will not be published. Required fields are marked *

The Beginner’s Handbook
From an introduction on how WordPress works to our recommendations on products and services.
👋 Hey there! We're Gaby and Mark
Every week we share tutorials and genuine reviews of WordPress products and services in our newsletter.
Thousands of people read it!
We’d love for you to join.
We’d love for you to join. Here’s what you’ll be getting:

A single weekly email directly to your inbox.