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:
If you enjoyed this post, make sure to subscribe to WP Mayor’s RSS feed.
17 Responses
Nice post bro, thank you.
thanks , I like your sharing remove image size in wordpress.
Nice Article.
thanks , I like your sharing remove image size in wordpress.
Nice post..
Regards
aswaja
This plugin can help you achieve this-
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?
Hi Jean Galea,
Thanks for share, very helpful for me..
Regards,,
What is a plugin created the size ? How can I find the name of the size ?
thanks , I like your sharing remove image size in wordpress.
Nice post..
Regards
sutopo
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/
THANK YOU!!!!!!
Thank You so much! This tutorial help me a lot π
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?
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…
Not having any luck with this in WP 3.6.1. Anyone else?
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.
Good idea Tomas, I amended the code.
you are my hero !!!