Grow your CSS skills. Land your dream job.

WordPress thumbnails

  • # June 25, 2011 at 12:21 pm

    Hey guys!

    I’m actually having some kind of a small problem I guess. Basically I want to have the possibility to have different thumbnail sizes. Im having 3 types of posts, the blog post, which has a small 274×9999 size. The Work post, which has a bigger 635×9999 size and the background post, which is a post type where I can upload backgrounds which people can download, but for previewing those backgrounds I want of course a thumbnail which will be 249×147 big.

    As I was reading the wp-codex I come across a function called add_image_size() – so from the documentary I’ve been reading, I can, with theme support (post-thumbnails), create a bunch of image sizes, so what I did was the following:

    add_theme_support('post-thumbnails');

    add_image_size( 'background-thumb', 249, 147 );
    add_image_size( 'blog-thumb', 274, 9999 );
    add_image_size( 'work-thumb', 635, 9999 );

    I added this code to my functions.php, added all sort of featured post images and added into my index.php the following (of course into the loop):

    < ?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'background-thumb' ); } ?>

    Well, it displays the usual 150×150 thumbnail of wordpress. Anyone know how I can make this work?

    Regards.

    # June 25, 2011 at 12:39 pm

    Nevermind, got it working by setting the fourth parameter of the add_image_size to true. By default it seems to be false.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".