Sure... it's pretty straightforward.
- First, create a new javascript file that will contain custom handlers for SWFUpload. Let's call it /mysite/javascript/swfupload_handlers.js
- Copy the fileQueued(file) function from /swfupload/javascript/handlers.js into your swfupload_handlers.js file, and rename it myFileQueued(file)
- Modify the function so that it throws a window confirm:
function myFileQueued(file) {
max_size = 2*1024*1024 // 2mb
if(file.size > max_size) {
if(!window.confirm('This is a big file. Are you sure you want to upload it?')) {
removeFileFromQueue(file.id);
return;
}
}
// everything below is the same...
try {
li = document.createElement("li");
li.setAttribute('id', 'file-' + file.id);
filename = new String(file.name);
if(filename.length > 30)
filename = filename.substr(0,29) + '...';
li.innerHTML = "<div class='queue-file-name'>" + filename + "</div><div class='queue-remove-btn'><a href='javascript:void(0);' onclick='return removeFileFromQueue(\""+file.id+"\");'>remove</a></div>";
txtFileNames.appendChild(li);
btnSubmit.style.display = 'block';
var progress = new FileProgress(file, 'file-' + file.id);
progress.setProgress(0);
meg = file.size > 1024*1024;
size = meg ? file.size/1024/1024 : file.size/1024;
rounded = Math.round(size*10)/10;
formatted = meg ? rounded : addCommas(Math.ceil(rounded));
suffix = meg ? 'M' : 'k';
progress.setStatus('Queued ('+formatted+suffix+')');
progress.fileProgressElement.childNodes[2].className = 'progressBarStatus queued';
} catch (e) {
}
}
- Lastly, we need to assign the new handler to SWFUpload. In your getCMSFields() function, include the script, and update the handler.
function getCMSFields() {
LeftAndMain::require_javascript('/path/to/swfupload_handlers.js');
SWFUploadConfig::set_var('file_queued_handler' => 'myFileQueued');
// etc..
}
Note: If you are using the ImagGalleryModule as it comes, you don't have your own getCMSFields() function to modify. In that case, just put it in your Page.php getCMSFields() function. The only downside is that it will apply the change on all your pages, but it sounds like that's okay with you.
Can't promise this is free of syntax errors or even if it will work, but hopefully it pushes you in the right direction.