add image size still doesn't work even after regenerating thumbnails

I'm encountering this very frustrating problem where add_image_size() just doesn't seem to work at all (in fact, I've never seen it even work before). By not working, I mean not resizing / crop (if I take away my CSS width / height, the thumbnail will be the exact size in which I have uploaded it).

I do have:

  1. add_theme_support( 'post-thumbnails' )
  2. add_image_size( 'small-thumb', 60, 60, true )
  3. the_post_thumbnail( 'small-thumb' )
  4. And most importantly, yes I've been regenerating my thumbnails close to 50 times now after changing the add_image_size() and it's not working.

Now I do have a question related to this problem: Does CSS styling like max-width/ max-height/ width / height or anything effect WordPress' thumbnail functions?

Anyone seem to know what else I can try to fix this?

Thanks

Topic add-theme-support images themes Wordpress

Category Web


Another thing to check if your expected images aren't being generated is to see if any image sizes are being generated.

Check your uploads directory. If there are not multiple entries for largish images (like the following)

  • image.jpg
  • imagex150x150.jpg
  • imagex300x300.jpg

Then you might not have the gd library installed.

if ( !extension_loaded('gd') || !function_exists('gd_info') ) {
    echo 'GD Library Not Installed';
} else {
    echo 'GD Library Available';
}

If the gd library isn't installed then you need to install it before wordpress can create your extra image sizes.


in my case, there was an error regenerating an image, because the image was too big! so the system did not regenerate smaller versions. you can see this happening, if the execution of the plugin regenerate thumbnails runns too fast on this particular image AND you can see via ftp, that there are NO smaller versions of the image. in this case, simply download the image, resize it to the half, delete the image in your medialib and then upload the smaller version and start regen.thumbs again. should work then.

btw.: the problematic image had 7594x3744@24bit@684kb


There are a couple of things to check here.

First, make sure that add_theme_support( 'post-thumbnails' ) is loaded before add_image_size( 'small-thumb', 60, 60, true )

You can always hook everything through a function to the after_setup_theme hook. I always add these in my theme setup function

function wpse_setup_theme() {
   add_theme_support( 'post-thumbnails' );
   add_image_size( 'small-thumb', 60, 60, true );
}

add_action( 'after_setup_theme', 'wpse_setup_theme' );

Apart from that, everything should work if you call your post thumbnail correctly in the loop.

On your question

Does CSS styling like max-width/ max-height/ width / height or anything effect WordPress' thumbnail functions?

No, it doesn't. CSS only manipulate how a thumbnail is displayed on the front end

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.