You can try using the jQuery ui scaling effect:
$(document).ready(function () {
resizeImage();
$(window).resize(function () {
resizeImage();
});
function resizeImage() {
var windowHeight = $(window).height() - $('#nav').height(),
windowWidth = $(window).width(),
percentage = 0;
if (windowHeight >= windowWidth) {
percentage = (windowWidth / $('#image').width() ) * 100;
}
else {
percentage = ( windowHeight / $('#image').height() ) * 100;
}
$('#image').effect('scale', { percent : percentage }, 1);
};
});
Tested and works great, however, you may need a few tweaks to get it exactly the way you like it.
Ryan source
share