1

I'm using the post thumbnail feature to show portfolio work, so for example <?php the_post_thumnail(); ?> the problem is I want to show a particular width of image only, which is 640 but because my pieces are website they have varying heights.

I'm using this code to create the images: add_image_size( '640', 480 ,true ); // 640x480 image size but it's specifying the height how can I ONLY specify the width??

Thanks

Ps. I know I could use CSS, but I want to actually create images at 640 wide and not use any timthumb stuff etc. Thanks

1 Answer 1

3

That is one strange add_image_size() call. You are missing size's name and mixing up string with integer. And you specify crop mode, when you actually need resize mode. Try this:

add_image_size( 'portfolio-shot', 640, 9999 );

Then fetch it with:

the_post_thumbnail( 'portfolio-shot' );

This should properly register image size under portfolio-shot name in soft-resize mode to width 640px. Note that (unless there were changes in recent WP versions, not sure) new size will be effective only for new uploads.

See this tutorial for excellent writeup on using related functions:

New in WordPress 2.9: Post Thumbnail Images

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.