Finally I came up with the solution to retrieve the image height using PHP getimagesize() and printing it as the ID of the image. Later, in JS I used: var contentheight = jQuery(‘.fluidimage’).attr(‘id’); to retrieve the height and perform the necessary action.
Here’s the PHP code:
<?php
$imageurl = $pathtoimage;
$image_size = getimagesize($imageurl);
$image_height = $image_size[1];
// For image width, use $image_width = $image_size[0];
?>
<img id="<?php echo $image_height; ?>" class="fluidimage" src="https://wordpress.stackexchange.com/questions/33728/<?php echo $imageurl; ?>" />
Here’s JS code to transfer the image height to JS variable, which you use in your own function within the JS:
var contentheight = jQuery('.fluidimage').attr('id');