Created
January 20, 2014 16:51
-
-
Save LinzardMac/8523824 to your computer and use it in GitHub Desktop.
Featured Image / First Image / Video A snippet that first checks if the post is a video, if so places the video in the header of the article. If not it then checks to see if there is a featured image, if so - display that, if not it checks for an embedded image if so - display that. If not, do nothing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$default_attr = array( | |
'alt' => 'photo' | |
); | |
$images =& get_children( array ( | |
'post_parent' => $post->ID, | |
'post_type' => 'attachment', | |
'post_mime_type' => 'image' | |
)); | |
$pics = get_first_image(); | |
if ( has_post_format( 'video' )) { | |
$vimeo = get_first_video(); | |
$embed_code = wp_oembed_get($vimeo[0]); | |
echo ($embed_code); | |
}elseif ( has_post_thumbnail() ) { | |
the_post_thumbnail( 'medium', $default_attr); | |
}elseif ( '' == get_the_post_thumbnail()&&!empty($pics)) { | |
?> | |
<img src="<?php echo $pics; ?>" alt="" /> | |
<?php | |
}else{ | |
echo 'nothing'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment