How To Get Featured Image URL, Height And Width In WordPress


If you want to get the URL, width and height of the featured image of a certain post / page you can use the below code.

$featuredImgDetails = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full"); 

The above code can be used in the post / page template file and $featuredImgDetails will be an array with

$featuredImgDetails[0] = Image URL
$featuredImgDetails[1] = Image Width
$featuredImgDetails[2] = Image Height

This entry was posted in Wordpress and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *