[wp-trac] [WordPress Trac] #11571: Provide easy way to return url of thumbnail image
WordPress Trac
wp-trac at lists.automattic.com
Wed Mar 31 12:50:48 UTC 2010
#11571: Provide easy way to return url of thumbnail image
-----------------------------+----------------------------------------------
Reporter: braindrain | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 3.1
Component: Post Thumbnails | Version: 2.9
Severity: normal | Keywords: reporter-feedback
-----------------------------+----------------------------------------------
Comment(by chrisscott):
Here's what I ended up doing to do this based on
`get_the_post_thumbnail()`:
{{{
function get_post_thumbnail_url( $post_id = NULL ) {
global $id;
$post_id = ( NULL === $post_id ) ? $id : $post_id;
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
$url = false;
if ( $post_thumbnail_id ) {
$size = apply_filters( 'post_thumbnail_size', 'post-
thumbnail' );
$image = wp_get_attachment_image_src( $post_thumbnail_id,
$size, false );
if ( $image ) {
list( $src, $width, $height ) = $image;
$url = $src;
}
}
return $url;
}
}}}
If this looks good to add to `post-thumbnail-template.php` let me know and
I'll submit a patch.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/11571#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list