jQThumb 是一款基於 jQuery 的縮略圖插件,它能夠很方便的制作指定的尺寸的縮略圖。 它支持 IE6 從 jQuery >=v1.3 或 Zepto (with zepto-data plugin) >=v1.1.3。
經測試支持的瀏覽器:
- Google Chrome
- Mozilla Firefox
- Safari
- Internet Explorer 6, 7, 8, 9 and 10
$('img').jqthumb({
classname: 'jqthumb', // 生成縮略圖的 div 類名. 默認是 jqthumb
width: '100%', // 剪裁后新圖片的寬度. 默認是 100px.
height: '100%', // 剪裁后新圖片的高度. 默認是 100px.
position: {
x: '50%', // 圖片 x 方向的位置. 默認 50%. 50% 的意思是圖片橫向的中心.
y: '50%' // 圖片 Y 方向的位置. 默認 50%. 50% 的意思是圖片縱向的中心.
},
source: 'src', // 圖像資源的屬性. 默認 src.
show: true, // TRUE = 處理后立即顯示. FALSE = do not show it. DEFAULT IS TRUE.
responsive: 20, // 只在舊的瀏覽器中使用. 0 to disable. DEFAULT IS 20
zoom: 1, // 放大倍數, 2 圖片實際大小的2倍. DEFAULT IS 1
method: 'auto', // 3 methods available: "auto", "modern" and "native". DEFAULT IS auto
before: function (oriImage) { // 每張圖片開始處理前回調函數.
alert("I'm about to start processing now...");
},
after: function (imgObj) { // 當每張圖片剪裁后回調函數.
console.log(imgObj);
},
done: function (imgArray) { // 所有圖片都剪裁后的回調函數
for (i in imgArray) {
$(imgArray[i]).fadeIn();
}
}
});
參考demo: http://www.bcty365.com/content-55-525-1.html
github :https://github.com/pakcheong/jqthumb