# How to use the thumbnail size with catch_that_image

Im using catch_that_image() to grab the first image of posts and use that as a thumb in a loop but the thumb is only 40px/40px and the image has to be scaled dramatically so I'd like to figure out how to use the thumbnail size image that gets stored to reduce scale size. Here's the function.

function catch_that_image() {
global $post,$posts;
$first_img = ''; ob_start(); ob_end_clean();$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content,$matches);
$first_img =$matches [1] [0];

return $first_img; }  ## 1 Answer I can't answer your question directly but I will give you a much simpler and more powerful solution to accomplish the same thing. Create a Custom field in the posts which should display thumbnails in a loop somewhere. Call it thumb or whatever you like. Upload a thumbnail image and paste its full url in the Custom field value field. Now put the following in your loop where you want the thumbnail image to show up: <?php$image = get_post_meta($post->ID, 'thumb', true); if($image) : ?>

Set width in css styling your loop to control the size of the thumbnail image. Preferably, create small resized thumbnail images in a photo editor and upload them. It will fasten pageload and save you bandwidth.

The method also lets you display a thumbnail image of choice. You can also have posts without images while they display thumbnails on your frontpage or on other pages.

• I really cant do that because I have front end posting for my users. Everytime they upload an image with a post it makes 3 separate sizes. I just wanna use the smallest for my thumbs. – Pollux Khafra Feb 19 '12 at 3:20
• You may be able to accomplish what you want with the featured image function in the post. See codex.wordpress.org/Post_Thumbnails and codex.wordpress.org/Function_Reference/get_the_post_thumbnail to retrieve thumbnails in the loop. There is also a plugin called "Get the image" which does basically the same thing but I it may also use the large images to create the thumbnails. – sarytash Feb 19 '12 at 15:41