WordPress

Sometime while creating a website there may be a situation to put a condition on the basis of image dimensions. For example show images only if they are greater than of 800 width.

To get image height and width WordPress does not provide as such its function. However using getimagesize() you can get image dimensions.

Example : to get image size of a featured image

$img_size = getimagesize(get_the_post_thumbnail_url());
$img_width =  $img_size[0];
$img_height = $img_size[1]; 

Leave a comment