Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

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.

share|improve this question
    
as for the default thumbnail (not the custom one) I struggled to get it with the_post-thumbnail('thumbnail'), I got lucky w/o parameters: the_post-thumbnail('thumbnail') –  Fronker Nov 12 '12 at 16:09
add comment

3 Answers

up vote 1 down vote accepted

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'); ?>
share|improve this answer
add comment

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

share|improve this answer
add comment

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!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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