tags:

views:

33

answers:

1

Hi,

I am trying to make a custom theme with a little summary of post. And i would like to show a thumb version of each first image associate with a post. If there's no image i just show a placeholder.

I am using custom values to add images to verious post templates.

This function didn't do the trick (only partly, just the one

function get_first_image($id) {

$PostID = $id; $all_images =& get_children('post_type=attachment&post_mime_type=image&post_parent=' . $PostID );

if($all_images) {

$arr_of_all_images = array_keys($all_images);

// Get the first image attachment from post $firstImage = $arr_of_all_images[0];

// Get the thumbnail url for the attachment // If you want the full-size image instead of the thumbnail, use wp_get_attachment_url() instead of wp_get_attachment_thumb_url(). $thumb_url = wp_get_attachment_thumb_url($firstImage);

// Build the string if($thumb_url !=''){ $First_thumb_image = '' . '< img src="' . $thumb_url . '" width="100" height="100" alt="Thumbnail Image" title="Thumbnail Image" />' . ''; } // Print the thum image form post return $First_thumb_image; } }

any tips

A: 

Hi,

Try these links and also there is a new feature in wordpress 2.9 Post Thumbnail you can also use it here is the link of it.

http://www.kremalicious.com/2009/12/wordpress-post-thumbnails/

Also, you can try these this is custom coded.

http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it

http://wordpress.org/support/topic/254493

Thanks

Professional2Hire