This function will return only the thumbnail URL for a given post
1 2 3 4 5 6 7 8 9 10 11 12 |
function get_the_post_thumbnail_as_bg( $post_id = NULL, $size = 'post-thumbnail', $attr = '' ) {
global $id;
$post_id = ( NULL === $post_id ) ? $id : $post_id;
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
$size = apply_filters( 'post_thumbnail_size', $size );
if ( $post_thumbnail_id ) {
$html = wp_get_attachment_image_src( $post_thumbnail_id, $size, false);
} else {
$html = '';
}
return $html[0];
} |