Skip to content

Instantly share code, notes, and snippets.

@joshdcomp
Created May 5, 2015 14:43
Show Gist options
  • Save joshdcomp/311a46651e7d8c324296 to your computer and use it in GitHub Desktop.
Save joshdcomp/311a46651e7d8c324296 to your computer and use it in GitHub Desktop.
Building the post thumbnail markup based on the original size
<?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];
}
<?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