A little snippet of code for getting preview image of a post.
<?php function prefix_get_image_thumb( $post_id ) { global $wpdb; $attachment_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_parent = '$post_id' AND post_status = 'inherit' AND post_type='attachment' ORDER BY post_date DESC LIMIT 1" ); $thumb = get_attachment_icon( $attachment_id ); echo $thumb; } ?>