$(function() { PhotoList_change(); initPhotoSwipeFromDOM('#PhotoList_i1','LI'); }); $(window).resize(function(){ PhotoList_change(); }) function PhotoList_change(){ //$("#PhotoList_i1 a").height($("#PhotoList_i1 a").width()* 0.66); //$("#PhotoList_i1 a").css("line-height",$("#PhotoList_i1 a").height()+"px"); //$("#PhotoList_i1 img").css({ "max-width":$("#PhotoList_i1 a").width(), "max-height": $("#PhotoList_i1 a").height() }); $("#PhotoList_i1").find("a").each(function(index, element){ //console.log($(this).width()); var that = this; imgReady($(this).attr("href"), function () { var size = (this.width) + "x" + (this.height); $(that).attr("data-size",size); }); }); }