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.
Table of Contents

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:

Stay in the know on the latest and greatest products and services in WordPress. We'll send you one email every week with new and trending tutorials and reviews.

17 Responses

  1. 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?

  2. 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/

  3. My image in my post is width =700px and the height is just auto.

    How to insert width=700px and height auto in this function?

  4. 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…

  5. 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.

Leave a Reply

Your email address will not be published.

Haven't found an answer to your question? Ask us about it.
Although we publish new posts every week, we might not be answering your questions. Recommend a topic and we'll do our best to cover it in one of our next posts.
From hosting plans to WooCommerce plugins and backup services, we have put together a collection of exclusive coupons and deals!
WP Mayor_Icon_white
WP Mayor Team

Get the latest reviews & tutorials, just like this one, curated in your inbox.