$post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC' ) );
// If there are attached images, count them
$total_images = ( $images ? count( $images ) : '0' );
// If there are attached images, get the first one
$image = ( $images ? array_shift( $images ) : false );
// If there are attached images, grab the markup of the first image
$image_img_tag = ( $image ? wp_get_attachment_image( $image->ID, 'thumbnail' ) : false );
// If there are no attached images, grab the markup of the first linked image in the_content()
$linkedimage = ( ! $images ? preg_match('/
]+>/i', get_the_content(), $linkedimages) : false );
// If there are no attached images, and no linked images, output some text
$spancontent = ( $linkedimage ? $linkedimages[0] : 'No Thumbnail Available' );
// Determine which output to use
$thumboutput = ( $image ? $image_img_tag : $spancontent );
// Determine what to use as the caption: either the attached-image caption, or the post excerpt
$thumbcaption = ( $image ? $image->post_excerpt : get_the_excerpt() );
?>
(Untitled)'; // set Post headline (H2) to "(Untitled)" if no Post Title is defined
} ?>