3

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

1
  • Are you using the_post_thumbnail inside The loop? Has the current post a featured image? Can you post your code?
    – cybmeta
    Commented Apr 21, 2014 at 7:00

3 Answers 3

5

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

3
  • I'll give that a try. What I've noticed is my add_theme_support() and add_image_size() is in 2 different functions. Does the add_image_size() function have to be called using that hook ( together with add_theme_support() )? Does it matter if it's called elsewhere?
    – Bobby
    Commented Apr 21, 2014 at 7:14
  • This can have an effect, as I said, it might be that your add_image_size() is running before add_theme_support(). I personally like to keep these all together in one function Commented Apr 21, 2014 at 7:17
  • 1
    I see the logic now. I finally see what's wrong now. The theme author has put several add_image_size()s in a function which he did not call (not hooked to after theme setup). Wow... Thanks a lot Pieter, got it working. I guess I'll just stick to your way from now.
    – Bobby
    Commented Apr 21, 2014 at 7:20
3

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.

0

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.