Last active
April 11, 2017 20:29
-
-
Save braginteractive/381692da71303d7812db3076d6acc8d7 to your computer and use it in GitHub Desktop.
Display YouTube thumbnail or Featured image
This file contains 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 | |
$url = get_post_meta( get_the_ID(), 'helpwp_url', true); | |
$yt_id = helpwp_youtube_id($url); | |
if ($url != '') : ?> | |
<a href="<?php the_permalink(); ?>"> | |
<img alt="<?php the_title(); ?>" class="card-img-top" src="https://img.youtube.com/vi/<?php echo esc_html( $yt_id ); ?>/maxresdefault.jpg"> | |
</a> | |
<?php else : ?> | |
<a href="<?php the_permalink(); ?>"> | |
<?php the_post_thumbnail( 'full', array('class' => 'card-img-top')); ?> | |
</a> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment