You can use wp_get_attachment_image_src() to retrieve an object with the post thumbnail information.
1 2 3 4 5 |
include ('wp-blog-header.php'); $post_id = $_REQUEST['id']; $img_id = get_post_thumbnail_id($post_id, $size = 'post-thumbnail', $attr = '' ); $image = wp_get_attachment_image_src( $img_id ); print_r($image); |
While methods such as get_the_post_thumbnail()
returns an image tag (),
wp_get_attachment_image_src()
returns a numeric array with the thumbnail info:
- $image[0] => url
- $image[1] => width
- $image[2] => height
You can also determine if a post has attachments by calling has_post_thumbnail()
, which returns a Boolean (true or false)
Thanks!
It actually looks like the only parameter available for
get_post_thumbnail_id
ispost_id
so there’s no need to specify$size
or$attr
there.However,
wp_get_attachment_image_src
does allow for the$size
parameter.//Frankie