$( window ).resize(function() {
$(“.backstretch img”).each(function(){
imageHeight = $(this).height();
imageWidth = $(this).width();
wrapperHeight = jQuery(window).height();
wrapperwidth = jQuery(window).width();
overlap = parseInt((wrapperHeight – imageHeight) / 2);
overlapwidth = parseInt((wrapperwidth – imageWidth) / 2);

var aj_height = parseInt(wrapperwidth / 1.7 );
var aj_width = parseInt(wrapperHeight * 1.7 );
if( aj_height >= wrapperHeight ){
var top_position = parseInt((wrapperHeight – aj_height) / 2 );
var left_position = 0;
$(this).parent().css({‘width’:wrapperwidth,’height’:wrapperHeight,’left’: ‘0px’, ‘top’: ‘0px’, ‘overflow’: ‘hidden’, ‘margin’: ‘0px’, ‘padding’: ‘0px’,’position’: ‘fixed’});
$(this).css({‘width’:wrapperwidth,’height’:aj_height,’left’: left_position, ‘top’: top_position, ‘overflow’: ‘hidden’, ‘margin’: ‘0px’, ‘padding’: ‘0px’,’max-width’:’none’,’position’:’absolute’});
//if(top_position >= 0){
// var top_position = 0;
// container.find(‘img’).parent().css({‘width’:wrapperwidth,’height’:wrapperHeight,’left’: ‘0px’, ‘top’: ‘0px’, ‘overflow’: ‘hidden’, ‘margin’: ‘0px’, ‘padding’: ‘0px’});
// container.find(‘img’).css({‘width’:aj_width,’height’:wrapperHeight,’left’: left_position, ‘top’: top_position, ‘overflow’: ‘hidden’, ‘margin’: ‘0px’, ‘padding’: ‘0px’});
//}

}
else{
var left_position = parseInt((wrapperwidth – aj_width) / 2 );
var top_position = 0;
$(this).parent().css({‘width’:wrapperwidth,’height’:wrapperHeight,’left’: ‘0px’, ‘top’: ‘0px’, ‘overflow’: ‘hidden’, ‘margin’: ‘0px’, ‘padding’: ‘0px’,’position’: ‘fixed’});
$(this).css({‘width’:aj_width,’height’:wrapperHeight,’left’: left_position, ‘top’: top_position, ‘overflow’: ‘hidden’, ‘margin’: ‘0px’, ‘padding’: ‘0px’,’max-width’:’none’,’position’:’absolute’});
if(left_position >= 0){
//var top_position = parseInt((wrapperHeight – aj_height) / 2 );
var left_position = 0;
$(this).parent().css({‘width’:wrapperwidth,’height’:wrapperHeight,’left’: ‘0px’, ‘top’: ‘0px’, ‘overflow’: ‘hidden’, ‘margin’: ‘0px’, ‘padding’: ‘0px’,’position’: ‘fixed’});
$(this).css({‘width’:wrapperwidth,’height’:aj_height,’left’: left_position, ‘top’: top_position, ‘overflow’: ‘hidden’, ‘margin’: ‘0px’, ‘padding’: ‘0px’,’max-width’:’none’,’position’:’absolute’});
}

}

});

})

Advertisements