In my functions.php i defined 2 dimensions i want to use on my site, small and custom-size and my file looks like this:
add_theme_support('post-thumbnails');
add_image_size('small', 120, '', true);
add_image_size('custom-size', 755, 220, true);
When i check my wp-content/uploads folder, except original image and 120px and 755px images i see several others dimensions (150px, 768px) and i was wondering why is that showing if i only have 2 dimensions (i am asking because i am on limited hosting and want to save on disk space because i host a lot of images).
Thank you!
There are generally three reasons that these other sizes could be showing up:
You had different thumbnail dimensions / image sizes in the past. Images are not re-created (or deleted) when you change image sizes, but you can use a plugin such as Regenerate Thumbnails to do this for you - just click the options it adds under the Tools menu, after you have changed your image sizes.
You have a plugin or theme installed that is creating additional image sizes. To track down what is doing this, you can either search through the files for add_image_size, or you could deactive plugins/change themes and then regenerate your thumbnails to see what the result is.
Wordpress has a new hidden image size for responsive images. This applies in the case of the 768px image. See this WP Core blog post for details. If you have no need for responsive images you could change the size that applies to this image using the instructions in that blog post (running eg. update_option('medium_large_size_w', '755') or even manually updating the option in the database - it's in the wp_options table). Again - regenerate thumbnails after doing this.
Related
I have a Wordpress site with more than 1000 product images. I recently added 2 custom image sizes, product-medium and product-large.
So, when I upload a new product featured image, it is hard cropping the medium and large sizes perfectly.
However, the already uploaded images don't crop themselves to these 2 sizes. Any suggestions would be helpful.
I have tried using the regenerating thumbnails plugin, but it doesn't generate the 2 custom image sizes.
add_image_size( 'product-medium', 640, 480, true );
add_image_size( 'product-large', 1024, 576, true );
There is no error message. All the newly uploaded images show the 2 custom resolutions but the older ones don't.
You need to regenrate the thumbnails for the existing uploaded theme. You can also use wp-cli command to do the same :
wp media regenerate
You can also do the same with the plugins available in WordPress repository.
It will re-create the images with existing image sizes.
I am using wordpress and woocommerce. I have one problem, i have created a system with downloads steam market items (names and pictures) and then creates products. But I have one problem, downloaded images that are used for product are automaticly resized to a different resolutions : 150x113 300x225 300x300 425x280 and original one. So it takes 5x space, which is a problem for me. How do i disable or fix that resizing problem.
Thanks.
I found this article here by WP Mayor. Basically you remove the code that produces them.
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');
place this in your functions.php file
UPDATE:
Also look here - Seems you just go to the media page, and set the other sizes to 0
By default, WordPress generates three sizes of each image that you upload. Themes and plugins can generate additional images sizes aswell.
First thing you should keep in mind is that the default image sizes are not harmful for your website.
If you already know this but you want to proceed anyway (or your space is really limited), you will need to do some steps to make Wordpress just keep the original image:
First you need to understand how many copies of an uploaded image
are generated by WordPress. You can check that using FTP client and
accesing /wp-content/uploads/ directory.
You can stop WordPress from generating default image sizes by
visiting Settings » Media in WordPress admin area. There you will
see default image sizes predefined by WordPress. You need to set
these sizes to 0 which will prevent WordPress from generating
default image sizes when you upload a new image.
Finally your theme might be generating other thumbnails (check it in
step 1), if this is the case look into your theme’s
functions.php file. Simply look for the code line containing:
add_image_size( 'homepage-thumb', 220, 180, true );
and
set_post_thumbnail_size( 150, 150 );
Note: WordPress uses the thumbnail image size for galleries and theme pages so they might break after you prevent their generation.
If you need further information I suggest you to check the original source of this post.
Hope this helps you.
MAKING YOUR IMAGES LIGHTER (JPEG COMPRESSION HOOK).
It don't take "5x space" but between x1.5 and x3 max, because other sizes are lighter, depending of their dimension and number of different sizes.
But you can make your images even much more lighter with this native hook:
add_filter( 'jpeg_quality', create_function( '', 'return 80;' ) );
You can tune the compression value replacing 80 by a number from 0 to 100. This hook doesn't compress your original image, but only all the others. If you want to use it you will need to paste it in the function.php file of your active child theme or theme.
IMAGES SETTINGS IN WOOCOMMERCE:
They are located in left menu Woocommerce > Settings > Products > Display. You can change all values to 0 (similar to Wordpress Media settings).
As the others answers suggested, you can unset somme of them programatically. Is better to keep thumbnails, because they are used to display images in the media library.
My goal is to create a website for a client that needs the site to be heavily based as image galleries.
I am making the site through Wordpress so the client can upload the pictures through the friendly wordpress admin panel and then the site will display a parent image for the gallery and several thumbnails (scrolling with Jquery).
My question is for advice on good ways to resize the images as thumbnails. Currently I have some "hack-ish" code that simply changes the image dimensions, but as far as I know this doesn't reduce loading time and is quite inefficient.
Any ides on how to do it better? Possibly by using PHP GD? Thanks!
Wordpress already does this on successful upload.
Besides creating the standard set of thumbnail, medium and large sizes, you can also enter custom sizes to create under the Settings -> Media section of the dashboard.
You can also add custom sizes in plugins and / or themes. See http://codex.wordpress.org/Function_Reference/add_image_size
Timthumb might be a good solution for this. The built-in wordpress media settings can only be set once for three different image options (thumbnail, medium and large). If you change the settings, anything already uploaded won't be readjusted. Most of the time this is acceptable, but for a photo heavy site, you might need more size options and dynamic adjustments. This simple php script will create any size image and save a cache copy for quick delivery. Lots of WordPress themes use it.
http://code.google.com/p/timthumb/
-- EDIT --
So, you know that advice about TimThumb I gave yesterday? Well, check out the big news today. Just make sure you're using the latest version.
http://ma.tt/2011/08/the-timthumb-saga/
WordPress his this nifty function tucked away image_resize, I'd recommend that if your looking to do this on the code size in one location. I have a small "library" I wrote to "help" with handling file uploads in WordPress, the git repo is here.
You can enable featured images for posts and set their size by using the following code in your function.php file:
add_theme_support('post-thumbnails');
set_post_thumbnail_size(107, 69, true);
but this sets the image size globally for any post types. Im using wordpress 3.0 and have created my own custom post type. Is it possible to apply a different featured thumbnail sizes for different post types?
Thanks
Scott
In your theme functions file, you can define new image sizes that apply to any images uploaded from then forward:
add_image_size('new-thumbnail-size',600,340, true)
Once you've defined a new image size, you can use the_post_thumbnail as usual but include the new image size to display that instead of the thumbnail default:
the_post_thumbnail( 'new-thumbnail-size' )
A little bit more detail: http://gavinsmith.me/2010/10/multiple-post-thumbnail-featured-image-sizes-in-wordpress/
To answer your question, currently (Version 3.4.1) it is not possible. And the reason is simple: If you upload a file to your media library your image is not related to any post nor even a post_type, so wordpress cannot know, that this file has to be resized into a different format.
Realizing your wish (as it is one of mine too) means, that the image has to be created, if an image is added to a post with a custom post type.
So until this might be realized (I do not expect that this will come in time) you have to define your custom image size globally dealing the disadvantage, that every file you are uploading will be stored multiple times (one per add_image_size() call), even if you will use only one image in your template.
In WordPress 2.5 and up, there's a built in Gallery feature that allows the option to add an image gallery to a Post or Page on your WordPress blog. (Ref: http://codex.wordpress.org/Gallery_Shortcode)
You can use a size option to specify the thumbnail size you would like displayed. Valid values include "thumbnail", "medium", "large" and "full". The default is "thumbnail". The size of the images for "thumbnail", "medium" and "large" can be configured in WordPress admin panel.
ie. [gallery size="medium"]
My Question: I'm trying to hack up the [gallery] shortcode to allow for custom sizes at the time of input -- not trying to do this through the admin panel. I'd like to use something like, [gallery size="145x160"].
Rather then download a bloated plugin, I'd rather work with what's already there and I'm not sure where I need to go in my file structure to make the changes. I'm familiar with PHP but I'm afraid I'll make a change and then when I update future versions of WP, it will overwrite what I've set in motion.
Could someone help me out with this?
Thank you very much!
I know this is late, but I found this question trying to accomplish the same thing.
The Gallery does not have any built-in filters to allow this, so I developed a solution that works below.
In your theme's functions.php file, add the following lines of code:
remove_shortcode('gallery');
add_shortcode('gallery', 'custom_size_gallery');
function custom_size_gallery($attr) {
// Change size here - medium, large, full
$attr['size'] = 'medium';
return gallery_shortcode($attr);
}
This will interrupt the normal gallery call, revise the size being used, and then call the built-in WordPress gallery.
Wordpress crunch the images in several size when you upload them. So you can not get your given size image unless you set it to the admin panel before uploading the image.
But you can add additional image size:
add_image_size( 'sidebar-thumb', 120, 120, true ); // Hard Crop Mode
add_image_size( 'homepage-thumb', 220, 180 ); // Soft Crop Mode
add_image_size( 'singlepost-thumb', 590, 9999 ); // Unlimited Height Mode
More about add_image_size() on Codex