Search code examples
wordpressfunctionsizethumbnailscustom-post-type

Function to get the original size of a featured image - full size


I need to know de original size of an uploaded image.

I have tried get_option( 'thumbnail_size_w' ) and get_option( 'thumbnail_size_h' ) and i get 150x150 but cant find the way to get the original size of this image instead of the thumbnail image.

I'm searching something like this get_option( 'full_size_w' ) and get_option( 'full_size_h' ) but it doesn't works.


Solution

  • You can retrieve the image source with size 'full'. The 'source' array contains the dimensions of the image size retrieved.

    $src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
    var_dump($src[1]); // image width
    var_dump($src[2]); // image height
    

    See https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/ for more information.