menu

Questions & Answers

WordPress - add_image_size does not work?

Following this guide, I want to add an additional image size:

if ( function_exists( 'add_theme_support' ) ) { 
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 150, 150, true ); // default Post Thumbnail dimensions (cropped)

    // additional image sizes
    // delete the next line if you do not need additional image sizes
    add_image_size( 'category-thumb', 500, 500 );
}

But I don't see this size (500 X 500) of image is created in /wp-content/uploads/... after uploading new images.

Any ideas what I have missed?

Answers(3) :

Just add this code.

if (function_exists('add_image_size')){
add_image_size( 'category-thumb',500,500, true);

}
Comments:
2023-01-22 00:15:05
This may well have fixed the issue for the OP. However, you've provided no explanation as to why your code should work and why the OPs code didn't...

this works only for new uploaded images! just delete the old ones and upload them again.

Comments:
2023-01-22 00:15:05
Or use the Regenerate Thumbnails plugin

make sure that gd2 extension is enabled