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

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

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

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

All suggestions are anonymous.

More from our blog...

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.

Post a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Stay updated with WP Mayor's newsletter showcase every week

Stay on top of every new WordPress innovation and latest launches. Receive all our fresh product reviews and expert guides directly in your inbox.

Hosting Survey 2024

Are you happy with your hosting provider or are you over-paying for too little? Have your say below!

"*" indicates required fields

What's the main reason you picked this host?*
How happy are you with your host?*

OPTIONAL: If you'd like to receive the results of this survey, please enter your details below.