Skip to content

Instantly share code, notes, and snippets.

@yao3060
Created September 6, 2012 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yao3060/3651021 to your computer and use it in GitHub Desktop.
Save yao3060/3651021 to your computer and use it in GitHub Desktop.
Get Featured Image with timthumb
<?php
$w = '350';
$h = '200';
if (has_post_thumbnail()) {
$large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
echo '<img class="wp-post-image" src="' . get_bloginfo("template_url") . '/timthumb.php?src=' . $large_image_url[0] . '&w=' . $w . '&h=' . $h . '" alt="' . get_the_title() . '" title="#htmlcaption' . get_the_ID() . '" /></a>';
} else {
echo '<img src="http://fakeimg.pl/350x200/?text=NoPictrue&font=lobster" alt="no pictrue" />';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment