I'm working on a conditional statement (in a loop) that looks for a featured image then grabs a default image if there is none, which I have figured out. But, I also wanted a way to pull the first image (or any image) attachment before going the route of the default image. Having trouble finding the right way to check for an attachment image, then display it.
I have added a specific thumbnail size, "featured-thumbs" in the functions.php file of my theme. It would be great if I could utilize this when displaying the attachment image.
Here's what I have so far:
<?php $count=0; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="span-9 subfeature append-bottom <?php if(++$count%2==0) echo 'last'?>">
<?php $thumb = get_the_post_thumbnail(); //Hack for Sitewide Tags Thumbnail process: assigns variable for use in conditional statement below ?>
<?php if (has_post_thumbnail()) {
the_post_thumbnail('thumbnail');
} else
if ( $thumb ) { //if not checks to see if there's a Sitewide Tags created thumbnail and uses that if there is
the_post_thumbnail();
} else {
echo '<img src="'.get_bloginfo("stylesheet_directory").'/images/maintenance/fallback-thumb.jpg" >';
}
?>
Thanks very much.