Featured Image Size

I am in the process of developing a new theme for my blog and am making a featured content slider. The issue that I am having is getting wordpress to force the image to the dimensions that I want it to be. The exact dimensions are 494px x 168px. I’ve tried simple using the_post_thumbnail( array(494, 168) );, but that didn’t work. I also tried adding a custom image size to my functions file. This would sometimes get the height right (but not always), but didn’t get the width right a single time. Could somebody please give me a way to force the dang image to be 494px X 168px?

1 Answer
1

For post thumbnails you can either crop and image to the thumbnail size or scale the image.
To enable crop you can call the thumbnail 1 of 2 ways.

  1. Name a size in the functions.php file like so:

    <?php add_image_size( 'my-post-thumbnail', 494, 168, true ); ?>
    

and then call it in the theme file

    <?php the_post_thumbnail('my-post-thumbnail'); ?>

The true tells wordpress to crop the image rather than scale, to scale leave true out.

  1. Call the size just in the theme file

    <?php the_post_thumbnail(494, 168, true); ?>
    

Also, the_post_thumbnail doesn’t work on images already uploaded. To test if the sizes truly aren’t working upload a new file after adding the new thumbnail size/calling it in your theme file.

Mark on WordPress has a good tutorial on Post Thumbnails
http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/

Leave a Comment