如果您需要設置在運行時轉換器,你將需要設置aurigma上傳的兩個額外的事件:1.BeforeUpload和2 BeforePackageUpload:
uploader = new Uploader('Uploader1');
...
$uploader->getClientEvents()->setBeforeUpload("BeforeUpload");
$uploader->getClientEvents()->setBeforePackageUpload("BeforePackageUpload");
...
然後實現在Javascript塊事件的代碼(腳本type =「text/javascript」)。
您將需要獲得所有添加到上傳窗格中的圖像的寬度和高度,並把這些值陣列。在BeforePackageUpload你應該把每個文件的寬度和高度的值,並比較它們設置所需的轉換器配合模式:
//set new arrays
var widths = [];
var heights = [];
function BeforeUpload() {
var uploader = $au.uploader('Uploader1');
count = uploader.files().count();
for (i = 0; i < count; i++) {
widths[i] = uploader.files().get(i).width();
heights[i] = uploader.files().get(i).height();
}
}
function BeforePackageUpload(index) {
var uploader = $au.uploader('Uploader1');
if (widths.shift() > heights.shift()) {
uploader.converters([{
mode: '*.*=Thumbnail',
thumbnailFitMode: 'Width',
thumbnailWidth: 500,
thumbnailHeight: 300,
thumbnailJpegQuality: 100
}]);
}
else
{
uploader.converters([{
mode: '*.*=Thumbnail',
thumbnailFitMode: 'Height',
thumbnailWidth: 300,
thumbnailHeight: 500,
thumbnailJpegQuality: 100
}]);
}
}
大 - 你有什麼問題嗎? – madflow 2012-04-24 14:27:26
編輯我的問題。希望這現在更有意義? – jaget 2012-04-24 14:38:18