This JavaScript plugin adapts an image to his parent element without cropping it.
By Worköholics.
Images from Unsplash
You can install image-adapter using Bower.
$ bower install image-adapter --save
You can use GitHub CDN.
<script src="https://raw.githubusercontent.com/workoholics/image-adapter/master/dist/image-adapter.js"></script>
You can download the code here and enjoy it.
To use image-adapter add class img-adapter
to your images.
<img class="img-adapter" src="images/test-image.jpg"/>
The horizontal image adapts to a horizontal container.
The horizontal image adapts to a vertical container.
The horizontal image adapts to a horizontal container.
The horizontal image adapts to a vertical container.