When queueing too large files in the multi-file uploader in IE or Opera, show error message and remove the file from the queue, fixes #19228
git-svn-id: http://svn.automattic.com/wordpress/trunk@19329 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
924ed5885c
commit
e72a2a2917
|
@ -276,7 +276,7 @@ function dndHelper(s) {
|
|||
}
|
||||
}
|
||||
|
||||
function uploadError(fileObj, errorCode, message) {
|
||||
function uploadError(fileObj, errorCode, message, uploader) {
|
||||
var hundredmb = 100 * 1024 * 1024, max;
|
||||
|
||||
switch (errorCode) {
|
||||
|
@ -287,7 +287,7 @@ function uploadError(fileObj, errorCode, message) {
|
|||
wpFileError(fileObj, pluploadL10n.invalid_filetype);
|
||||
break;
|
||||
case plupload.FILE_SIZE_ERROR:
|
||||
wpQueueError( pluploadL10n.file_exceeds_size_limit.replace('%s', fileObj.name) );
|
||||
uploadSizeError(uploader, fileObj);
|
||||
break;
|
||||
case plupload.IMAGE_FORMAT_ERROR:
|
||||
wpFileError(fileObj, pluploadL10n.not_an_image);
|
||||
|
@ -327,10 +327,15 @@ function uploadError(fileObj, errorCode, message) {
|
|||
}
|
||||
}
|
||||
|
||||
function uploadSizeError( up, error ) {
|
||||
var file = error.file;
|
||||
function uploadSizeError( up, file, over100mb ) {
|
||||
var message;
|
||||
|
||||
jQuery('#media-items').append('<div id="media-item-' + file.id + '" class="media-item error"><p>' + pluploadL10n.file_exceeds_size_limit.replace('%s', file.name) + '</p></div>');
|
||||
if ( over100mb )
|
||||
message = pluploadL10n.big_upload_queued.replace('%s', file.name) + ' ' + pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>');
|
||||
else
|
||||
message = pluploadL10n.file_exceeds_size_limit.replace('%s', file.name);
|
||||
|
||||
jQuery('#media-items').append('<div id="media-item-' + file.id + '" class="media-item error"><p>' + message + '</p></div>');
|
||||
up.removeFile(file);
|
||||
}
|
||||
|
||||
|
@ -426,8 +431,19 @@ jQuery(document).ready(function($){
|
|||
uploader.init();
|
||||
|
||||
uploader.bind('FilesAdded', function(up, files) {
|
||||
var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10);
|
||||
|
||||
$('#media-upload-error').html('');
|
||||
uploadStart();
|
||||
|
||||
if ( max > hundredmb && up.runtime != 'html5' ) {
|
||||
plupload.each(files, function(file){
|
||||
if ( file.size > hundredmb ) {
|
||||
uploadSizeError( up, file, true );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
up.refresh();
|
||||
up.start();
|
||||
});
|
||||
|
@ -445,12 +461,8 @@ jQuery(document).ready(function($){
|
|||
});
|
||||
|
||||
uploader.bind('Error', function(up, err) {
|
||||
if ( err.code == plupload.FILE_SIZE_ERROR ) {
|
||||
uploadSizeError(up, err);
|
||||
} else {
|
||||
uploadError(err.file, err.code, err.message);
|
||||
up.refresh();
|
||||
}
|
||||
uploadError(err.file, err.code, err.message, up);
|
||||
up.refresh();
|
||||
});
|
||||
|
||||
uploader.bind('FileUploaded', function(up, file, response) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -202,6 +202,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
'http_error' => __('HTTP error.'),
|
||||
'upload_failed' => __('Upload failed.'),
|
||||
'big_upload_failed' => __('Please try uploading this file with the %1$sbrowser uploader%2$s.'),
|
||||
'big_upload_queued' => __('%s exceeds the maximum upload size for the multi-file uploader when used in your browser.'),
|
||||
'io_error' => __('IO error.'),
|
||||
'security_error' => __('Security error.'),
|
||||
'file_cancelled' => __('File canceled.'),
|
||||
|
@ -221,7 +222,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
// cannot use the plupload.full.js, as it loads browserplus init JS from Yahoo
|
||||
$scripts->add( 'plupload-all', false, array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4'), '1511-20111112');
|
||||
|
||||
$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array('plupload-all', 'jquery'), '20111114');
|
||||
$scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array('plupload-all', 'jquery'), '20111117');
|
||||
$scripts->localize( 'plupload-handlers', 'pluploadL10n', $uploader_l10n );
|
||||
|
||||
// keep 'swfupload' for back-compat.
|
||||
|
|
Loading…
Reference in New Issue