Copy Code code as follows:
JQuery.fn.autoZoomLoadImage = function (scaling, width, height, loadpic) {
if (loadpic = = null) Loadpic = "Loading.gif";
Return This.each (function () {
var t = $ (this);
var src = $ (this). attr ("src");
var img = new Image ();
Alert ("Loading")
IMG.SRC = src;
Automatically scale pictures
var autoscaling = function () {
if (scaling) {
if (img.width > 0 && img.height > 0) {
if (img.width/img.height >= width/height) {
if (Img.width > width) {
T.width (width);
T.height ((img.height * width)/img.width);
}
else {
T.width (Img.width);
T.height (Img.height);
}
}
else {
if (Img.height > height) {
T.height (height);
T.width ((img.width * height)/img.height);
}
else {
T.width (Img.width);
T.height (Img.height);
}
}
}
}
}
Cached pictures are automatically read under processing FF
if (img.complete) {
Alert ("gettocache!");
AutoScaling ();
Return
}
$ (this). attr ("src", "");
var loading = $ ("T.hide ();
T.after (loading);
$ (IMG). Load (function () {
AutoScaling ();
Loading.remove ();
T.attr ("src", this.src);
T.show ();
Alert ("finally!")
});
});
}