").attr("src", $(img).attr("data-src")).load(function () { realWidth = this.width; realHeight = this.height; if (realWidth >= _w) { $(img).css("max-width", "100%"); } else { $(img).css("width", realWidth + 'px').css("height", realHeight + 'px'); } }); }); });