General Question

klaas4's avatar

Resize thumbnail to fit in WordPress theme?

Asked by klaas4 (2186points) July 4th, 2011

Hi Fluther!

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


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! :)

Observing members: 0 Composing members: 0

2 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




to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
Knowledge Networking @ Fluther