Specify automatically the height and weight of the images

Instead of your code for image, use this following.

<?php $thumb_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 120, 90, true ); ?>
<img src="https://wordpress.stackexchange.com/questions/172495/<?php echo $thumb_image[0]; ?>" alt="<?php echo esc_html( get_the_title() ); ?>" width="<?php echo $thumb_image[1]; ?>" height="<?php echo $thumb_image[2]; ?>" />    

Let me explain a little what it’s doing. We are returning PHP array of attachment image with WordPress function wp_get_attachment_image_src.

This PHP array containing: (from Codex)

  • [0] => url
  • [1] => width
  • [2] => height
  • [3] => boolean: true if $url is a resized image, false if it is the original.

So we added those values in our image tag.
Try it and let me know how it goes.