How to Remove Image Sizes in WordPress

If you purchase through a link on our site, we may earn a commission. Learn more.

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

Discover more from our , archives ↓

Popular articles ↓

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.

Share Your Thoughts

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

Claim Your Free Website Tip 👇

Leave your name, email and website URL below to receive one actionable improvement tip tailored for your website within the next 24 hours.

"They identified areas for improvement that we had not previously considered." - Elliot

By providing your information, you'll also be subscribing to our weekly newsletter packed with exclusive content and insights. You can unsubscribe at any time with just one click.