Can’t get image size set with set_post_thumbnail_size() function

I have a problem with set_post_thumbnail_size() function, which seems it doesn’t work. Or at least it doesn’t work correctly.

I have set a thumbnail size 75x75px in WordPress settings under the media section and have also set another thumbnail size in the functions.php using:

Read More
set_post_thumbnail_size(80, 80, true);

How are these two settings supposed to work? I believe the one that I set in the function.php (80x80px) should override the other in the media settings. Am I correct?

This is not the case though. Both sizes of the image exist in my uploads folder and what is worst I can’t get the one I set with set_post_thumbnail_size() no matter what.

When I call

the_post_thumbnail($id, 'thumbnail');

I get the one set in the media settings and not the one I set in my theme’s functions.php. How can I get the other?

UPDATE: It seems I messed up ‘thumbnail’ and ‘post-thumbnail’. In media settings I can set the thumbnail size, which is another image size as ‘medium’ and ‘large’. Using set_post_thumbnail_size() I can set the post-thumbnail (aka featured image) size. Sorry for the mess and thanks for the answers.

Related posts

Leave a Reply

3 comments

  1. They work independently of eachother. You need to call the one you created in the functions.php.

    So in your functions.php you would have something like:

    if (function_exists('add_theme_support')) {
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 75, 75, true ); // default thumbnail size
    add_image_size('my-custom-thumb', 80, 80, true); //custom size
    }
    

    and then to call your custom thumbnail you would add this where you want it to appear:

    <?php echo the_post_thumbnail('my-custom-thumb'); ?>
    
  2. As the original question actually referred to thumbnail and not post-thumbnail, you can update the thumbnail size in functions.php using:

    // we can override the defaults
    update_option('thumbnail_size_w', 170);
    update_option('thumbnail_size_h', 170);
    

    This works for medium and large too:

    update_option('medium_size_w', 768);
    update_option('medium_size_h', 576);
    
    update_option('large_size_w', 1020);
    update_option('large_size_h', 768);
    

    Hopefully that helps!

  3. AFAIK set_post_thumbnail_size() will not override media setting.

    make sure your theme support for post-thumbnails

    if ( function_exists( 'add_theme_support' ) ) {
        add_theme_support( 'post-thumbnails' );
            set_post_thumbnail_size( 75, 75,true );
    }
    

    and define the image as featured image in Edit Post and Edit Page screens
    to call the post-thumbnail

    if ( has_post_thumbnail() ) {
        the_post_thumbnail();
    }
    

    OR

    echo get_the_post_thumbnail($id); 
    

    REF : http://codex.wordpress.org/Post_Thumbnails