PabloVallejo
2/5/2014 - 1:32 PM

Post_Model::thumb

Post_Model::thumb

<?php 


/**
* Get the post thumbnail src
*
* <code>
*
*		// Print post thumbnail
*		<img src="<?php echo Post_Model::thumb(); ?>" />
*
*
*		// Specifying the post ID
*		<img src="<?php echo Post_Model::thumb( 10 ); ?>" />
*
* </code>
*
* @param { int } Post ID
* @return { str } thumbnail Src
*/
public static function thumb( $post_id = null, $size = '' ) {
	global $post;

	$fallback = IMAGES_URL . 'home/home-list.jpg';
	$post_id = is_numeric( $post_id ) ? $post_id : $post->ID;

	if ( ! has_post_thumbnail( $post_id ) )
		return;

	$attach_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), $size );

	return has_post_thumbnail( $post_id ) ?
		$attach_image[ 0 ] : $fallback;

}

?>