My website has two panels: a left panel for menus (370px width) and a right panel for content, mostly images, with padding-left set to 370px. I am currently using jQuery to resize images on document load, but they are stretching out of proportion. How can I crop all images while maintaining their aspect ratio? Here is my current code:
JS
jQuery(document).ready(function(){
var windowWidth = $(window).width(); //retrieve current window width
var windowHeight = $(window).height(); //retrieve current window height
var finalWidth = windowWidth - 370;
jQuery('.rightside > img').css({'height':windowHeight,'width':finalWidth});
jQuery('.rightside').css('height',windowHeight);
});
HTML
<div class="rightside">
<img class="project_image" src="" />
<img class="project_image" src="" />
<img class="project_image" src="" />
<img class="project_image" src="" />
<img class="project_image" src="" />
</div>
At the current resolution of 1920x1080, the right-side panel measures 1533x924 in width & height.