Ok I found something that looks like that code but it looks a lot more complicated (probably because of the theme I’m using…
/* this function gets thumbnail from Post Thumbnail or Custom field or First post image */
function get_thumbnail($width=100, $height=100, $class=”, $alttext=”, $titletext=”, $fullpath=false, $custom_field=”)
{
global $post, $shortname, $posts;
$thumb_array[‘thumb’] = ”;
$thumb_array[‘use_timthumb’] = true;
if ($fullpath) $thumb_array[‘fullpath’] = ”; //full image url for lightbox
if ( function_exists(‘has_post_thumbnail’) ) {
if ( has_post_thumbnail() ) {
$thumb_array[‘use_timthumb’] = false;
$args=”;
if ($class <> ”) $args[‘class’] = $class;
if ($alttext <> ”) $args[‘alt’] = $alttext;
if ($titletext <> ”) $args[‘title’] = $titletext;
$thumb_array[‘thumb’] = get_the_post_thumbnail( $post->ID, array($width,$height), $args );
if ($fullpath) {
$thumb_array[‘fullpath’] = get_the_post_thumbnail( $post->ID );
$thumb_array[‘fullpath’] = preg_match_all(‘/<img.+src=[\'”]([^\'”]+)[\'”].*>/i’, $thumb_array[‘fullpath’], $matches);
$thumb_array[‘fullpath’] = $matches[1][0];
};
}
};