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