Created
May 5, 2015 14:43
-
-
Save joshdcomp/311a46651e7d8c324296 to your computer and use it in GitHub Desktop.
Building the post thumbnail markup based on the original size
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 | |
/** | |
* Given a post ID, return the permalink for the original size post thumbnail | |
* | |
* @param int $ID post id | |
* @return string deep link for a post thumbnail | |
*/ | |
function _thumb_link($ID) { | |
$toReturn = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); | |
return $toReturn[0]; | |
} |
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 | |
$ID = get_the_ID(); | |
$postLink = get_permalink(); | |
$thumb = !empty(_thumb_link($ID)) | |
? _thumb_link($ID) | |
: 'http://placehold.it/255x130'; | |
?> | |
<a href="<?php echo $postLink; ?>" class="entry--thumb"> | |
<img | |
class="entry--thumb_img" | |
src="<?php echo $thumb; ?>" | |
/> | |
</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment