General Question

klaas4's avatar

Resize thumbnail to fit in WordPress theme?

Asked by klaas4 (2189points) July 4th, 2011
2 responses
“Great Question” (0points)

Hi Fluther!

I’m making a custom theme and I need Wordpress to resize my images on the fly. I’m currently using

the_post_thumbnail(array(208,158));

inside a loop to display the thumbnail. No problem with the actual code, but let’s say the image is 208px in width and 130px in height. WordPress finds no need to resize it to fit the 208×158 frame.

Any WP experts in here? How would I go about doing this? I’m using WordPress 3.1.4.

Thanks! :)
—Davey

Observing members: 0
Composing members: 0

Answers

klaas4's avatar

Nevermind. The solution is timthumb.php.

For anyone interested.

$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,‘large’);
echo ’<img src=”’. get_bloginfo(‘template_directory’) .’/timthumb.php?src=’. $image_url[0] .’&h=158&w=208” alt=”’. get_the_title() .’” />’;

kaiharris's avatar

WordPress 2.5 and later include a built-in option to change the size of thumbnails.

Answer this question

Login

or

Join

to answer.

Mobile | Desktop


Send Feedback   

`