Display image in div , in case its height is more than width (portrait), show mid part of image

Display image in div , in case its height is more than width (portrait), show mid part of image

Dear Sir

pls refer


all images in landscape (height less than width)  like 


are properly aligned

however the images in portrait  (height more than width)

like


or


only top part is visible

for landscape images there is no issue

However in case of Portrait type of images (where in the height is more than width)
only top part is visible

I want to show mid part of the image in case of portrait type of image instead of top part

i feel this is possible using jquery

pls pls help



I tried


used css as follow

  1. /* Thumbnail styling */

  2. .thumbnail {
  3.   position: relative;
  4.   width: 200px;
  5.   height: 200px;
  6.   overflow: hidden;
  7. }
  8. .thumbnail img {
  9.   position: absolute;
  10.   left: 50%;
  11.   top: 50%;
  12.   height: 100%;
  13.   width: auto;
  14.   -webkit-transform: translate(-50%,-50%);
  15.       -ms-transform: translate(-50%,-50%);
  16.           transform: translate(-50%,-50%);
  17. }
  18. .thumbnail img.portrait {
  19.   width: 100%;
  20.   height: auto;
  21. }
and PHP script as follow (dynamic ...image names are fetched from database)

  1. <div class="thumbnail">
  2.    <img src="<?php echo $srows['actualimage'];?>"  style="border:3px solid #ccc ;" >
  3.    </div>
however being responsive (my personal opinion) 
the crop is not working

refer following link after using crop



in need of solution