How I can display a default image if $image is false ?
Thanks.
Antonio
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'grid_6' ); ?>
<?php if( $image ) : ?>
<div class="scroller-image" style="padding-top:5px;">
<?php echo "<img style='float: left; margin-right: 5px;' src='"; bloginfo('template_url'); echo "/timthumb.php?src=".$image[0]."&h=84&w=84&zc=1' />"; ?>
</div><!-- .scroller-image (end) -->
<?php endif; ?>
<?php endif; ?>
Daniel Yoen answers:
try this :
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'grid_6' ); ?>
<?php if( $image ) : ?>
<div class="scroller-image" style="padding-top:5px;">
<?php echo "<img style='float: left; margin-right: 5px;' src='"; bloginfo('template_url'); echo "/timthumb.php?src=".$image[0]."&h=84&w=84&zc=1' />"; ?>
</div><!-- .scroller-image (end) -->
<?php else : ?>
<div class="scroller-image" style="padding-top:5px;">
<?php echo "<img style='float: left; margin-right: 5px;' src='default image link here' />"; ?>
</div><!-- .scroller-image (end) -->
<?php endif; ?>
hope this help :-)
natspace comments:
It works perfectly!
Thanks Daniel :)
-natspace
natspace comments:
How I can give money to u?
Daniel Yoen comments:
hello,
you can mark complete the question and vote :-)
-daniel
natspace comments:
Ok but how I can mark complete the question? Sorry, I'm a new here...
Daniel Yoen comments:
I don't know, maybe this : http://blog.tailormadeanswers.com/2011/04/22/voting-assign-prize-money/
Hariprasad Vijayan answers:
Try this
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'grid_6' ); ?>
<?php if(isset($image[0])){ ?>
<div class="scroller-image" style="padding-top:5px;"> <?php echo "<img style='float: left; margin-right: 5px;' src='"; bloginfo('template_url'); echo "/timthumb.php?src=".$image[0]."&h=84&w=84&zc=1' />"; ?> </div>
<?php } else { ?>
<div class="scroller-image" style="padding-top:5px;"> <?php echo "<img style='float: left; margin-right: 5px;' src='<default image link>' />"; ?> </div>
<?php } ?>