How stop wordpress creating thumbnails? - wordpress

How can I stop Wordpress from making thumbnails? It uses a lot of my nodes, and memory!
How can I do this?
PS: My Wordpress site creates 3 images per uploaded image. (and I have galleies of 20-30 images per article => sooooooooo much nodes and memory)...

It's very simple to do this...
You have no visible option "stop Wordpress making thumbnails".
You must do the following:
Go to Settings -> Media
Uncheck "Crop thumbnail to exact dimensions (normally thumbnails are proportional)" if is checked
Set at Thumbnail size, Medium size and Large size the Width and Height to 0
Now Wordpress won't create you thumbnails.
I hope this will help you!

In wordpress when you upload new image that wordpress set it's thumbnail images accoring to set from admin panel or define in theme functions file.
Here is simple way for stop generating thumbnails by simple put below code in your theme function file.
function chnage_filter_image_sizes($sizes){
$sizes = array();
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'chnage_filter_image_sizes');
Here if you want to generate own thumbnails with custome width and height whenever upload any image than just put parametes as below.
function chnage_filter_image_sizes($sizes){
$sizes = array('thumbnail_name'=>array('width'=>'120','height'=>'120','crop'=>true));
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'chnage_filter_image_sizes')

Related

Limit images sizes created by theme / plugins

I am trying to limit the images sizes created by themes and plugins.
For instance, if you upload an image to a woocommerce product, I only want the sizes set by woocommerce to be created.
The same for my custom slider plugin; When I upload a slider, I only want the image sizes I set for the slider custom post type to be generated.
Then, to make it more complicated, I created a couple of plugins that don't use CPT, but instead an options page (like my testimonial plugin).
I thought this may work, but it doesn't.
if( get_post_type() == 'product' ) {
add_image_size( '1280-thumb', 1280 );//1280px wide, free high
}
Thank you
Okay, first of all, do regenerate thumbnails and set your image size with same add image size function then check if the image will be cropped or not as per your custom image size try with this one.
add_image_size( 'custom-size', 220, 180, true );
Using this plugin you can do regenerate your existing thumbnails https://wordpress.org/plugins/regenerate-thumbnails/.

Wordpress image resize quality could be better

I do use the automatic resize function of wordpress and have already set the image quality for jpgs to a much higher quality via the functions.php file like so:
add_filter('jpeg_quality', function($arg)
{
return 90;
}
);
However, the resulting image quality is still not very good. The pictures could need a sharpening pass or a different resize algorithm.
I did not find any way to tell wordpress to use a different algorithm so far - does anyone know a hook or something similar to increase the quality?
All you need to do is paste the following code in your theme’s functions.php file or your site-specific plugin.
function gpp_jpeg_quality_callback($arg)
{
return (int)100;
}
add_filter('jpeg_quality', 'gpp_jpeg_quality_callback');
Or
add_filter( 'jpeg_quality', create_function( '', 'return 100;' ) );
You can change from admin panel .
Setting >> media >> here you can add you size for images.
for thumbnail,small ,large images .

Images of different sizes in uploads folder wordpress

When add an image in media, creates multiple images of different sizes.
When upload image.png, create image-150x112.png
I want have only image upload. How do this?
Wordpress automatically resizes the images to use as thumbnails or posts so to cut down the amount of bandwidth being used up.
If you really really want to, you can unset them but i would advise against it if your using very large images which will use up a lot bandwidth.
Option 1
Go into settings -> media and change all of the numbers to 0. This means the resize wont happen.
Option 2
Add this code to your functions.php file in the theme
function unset_image_resizing() {
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['large']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'unset_image_resizing');

Different thumbnails sizes for different custom post types, and creating thumbnails for featured images only

I've got a wordpress site with a few custom post types. Each custom post type shows a list page, basically displaying a featured image and a title, and then you can click through to a detail page with a bunch more images.
I only need to resize uploaded "feature images". If an uploaded image isn't used as a feature image, I don't need a thumbnail for it. Furthermore, each custom post type shows a different sized feature image.
So, what I want to do is say:
a) Only create thumbnails for feature images
b) Create certain sizes for certain post types, and not for others.
Is this possible? At the moment, EVERY uploaded image is getting 5 thumbnail sizes, and my wp-content directory is WAAAY bigger than it needs to be!
Thanks in advance.
Ok I found a solution using the intermediate_image_sizes filter hook. Place this code in your functions.php and replace the 'post_type' and 'img_size_name' with the names of your post and desired image size.
add_filter( 'intermediate_image_sizes', function($sizes){
$type = get_post_type($_REQUEST['post_id']);
foreach($sizes as $key => $value){
if($type=='post_type' && $value != 'img_size_name'){
unset($sizes[$key]);
}
}
return $sizes;
});
To avoid waste of space, the best solution is to use phpthumb (http://phpthumb.sourceforge.net/) inside your page templates.

Setting thumbnail featured image size not working properly

Hi I just started today on creating my first Wordpress Theme and I am trying to create a featured Image for each post.Aldo I have managed to acomplish that it seems that the sizes I am giving it are not taking effect.Here is my code:
if(function_exists('add_theme_support')){
add_theme_support('post-thumbnails' , array('post'));
set_post_thumbnail_size(200,120);
}
if(function_exists('has_post_thumbnail') && has_post_thumbnail()){
the_post_thumbnail();
}
It seems that my featured images are not always set to the same size.For example if the image is smaller then what size I set it will remain the same , for big images the width is the same but for some the height is different.
What am I doing wrong here?
Are you setting the thumbnail size in functions.php? It will not work properly if it's just in index.php or another theme file.
From the codex:
This feature must be called before the init hook is fired. That means
it needs to be placed directly into functions.php or within a function
attached to the 'after_setup_theme' hook. For custom post types, you
can also add post thumbnails using the register_post_type function as
well.
the_post_thumbnail() displays the thumbnail and should be placed where you want the thumbnail to display.

Resources