Horje
Custom image sizes not being generated. - Wordpress Solution
[Solved] - Custom image sizes not being generated. - Wordpress Solution
Try following codes
I used to upload an image and wordpress would create the image sizes for my theme. Since I upgraded to 3.5 it no longer works. Wordpress only generates the image sizes set in media options. I can check this by simply checking the uploads folder and seeing the sizes of images that have been made. Here's is my function that used to work. Has something changed in the new version of wp that stops the custom sizes being made. I prefer to code solutions and not use plugins please.
//BEGIN Activate Thumbnails
if ( function_exists( 'add_theme_support' ) )
add_theme_support( 'post-thumbnails' );

set_post_thumbnail_size( 615, 9999);
add_image_size( '100-thumb', 100, 100);
add_image_size( '300-thumb', 300, 200 );
add_image_size( '455-thumb', 455, 9999 );


Solution - 1

set_post_thumbnail_size( 615, 9999);

if ( function_exists( 'add_image_size' ) ) {
 add_image_size( 'thumb-100', 100, 100);
 add_image_size( 'thumb-300', 300, 200 );
 add_image_size( 'thumb-455', 455, 9999 );
}
 
add_filter('image_size_names_choose', 'my_image_sizes');
function my_image_sizes($sizes) {
        $addsizes = array(
                "thumb-100" => __( "100 pixels"),
                "thumb-300" => __( "300 pixels"),
                "thumb-455" => __( "455 pixels")
                );
        $newsizes = array_merge($sizes, $addsizes);
        return $newsizes;
}
For thumbnail resizing, you can use the following code (optionally)
update_option('thumbnail_size_w', 615); // update thumbnail width
update_option('thumbnail_size_h', 999); // update thumbnail height, unlimited here in this case to keep the aspect ratio
update_option('thumbnail_crop', 0); // no cropping
Also make sure you have the following in functions.php
if ( function_exists( 'add_theme_support' ) ) {
	add_theme_support( 'post-thumbnails' ); // The important part
        set_post_thumbnail_size( 615, 9999 ); // default Post Thumbnail dimensions   
}


Solution - 2

you can try Hard Crop mode

add_image_size( '100-thumb', 100, 100, true);

add_image_size( '300-thumb', 300, 200, true);

add_image_size( '455-thumb', 455, 9999, true);


Solution - 3

Try having letters before numbers such as:

add_image_size( 'thumb-100', 100, 100);
Even if it doesn't fix the problem, it's a good practice.

Date: 2022-10-21 05:02:48
Category: Wordpress
More for You