Display attachment resolution size

The wp_get_attachment_img_src( $attachment_id ) function returns an array consisting of:

  • The URL to the img
  • width
  • height

To get the actual attachment/thumbnail/featured image ID, you want to use

$att_ID = get_post_thumbnail_id( get_the_ID() );

in the loop. Outside the loop, you would have to get the Post ID somehow to feed it in as get_the_ID() refers to the currently looped post object which isn’t present there. The whole call would look like this:

$img = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ) );
printf(
    'Image size: %dpx × %dpx (%s)',
    absint( $img[1] ),
    absint( $img[2] ),
    is_bool( $img[3] ) AND $img[3]
        ? 'cropped'
        : 'uncropped',
);

The result would display as:

Image size: 600px × 320px