Uploader: Display a more specific error message when a file exceeds the file size limit. see #21390.

git-svn-id: http://core.svn.wordpress.org/trunk@22822 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-22 12:18:17 +00:00
parent 440ec7ef3d
commit 14af860aab
1 changed files with 7 additions and 2 deletions

View File

@ -226,6 +226,8 @@ window.wp = window.wp || {};
for ( key in Uploader.errorMap ) { for ( key in Uploader.errorMap ) {
if ( pluploadError.code === plupload[ key ] ) { if ( pluploadError.code === plupload[ key ] ) {
message = Uploader.errorMap[ key ]; message = Uploader.errorMap[ key ];
if ( _.isFunction( message ) )
message = message( pluploadError.file, pluploadError );
break; break;
} }
} }
@ -245,14 +247,17 @@ window.wp = window.wp || {};
Uploader.errorMap = { Uploader.errorMap = {
'FAILED': pluploadL10n.upload_failed, 'FAILED': pluploadL10n.upload_failed,
'FILE_EXTENSION_ERROR': pluploadL10n.invalid_filetype, 'FILE_EXTENSION_ERROR': pluploadL10n.invalid_filetype,
// 'FILE_SIZE_ERROR': '',
'IMAGE_FORMAT_ERROR': pluploadL10n.not_an_image, 'IMAGE_FORMAT_ERROR': pluploadL10n.not_an_image,
'IMAGE_MEMORY_ERROR': pluploadL10n.image_memory_exceeded, 'IMAGE_MEMORY_ERROR': pluploadL10n.image_memory_exceeded,
'IMAGE_DIMENSIONS_ERROR': pluploadL10n.image_dimensions_exceeded, 'IMAGE_DIMENSIONS_ERROR': pluploadL10n.image_dimensions_exceeded,
'GENERIC_ERROR': pluploadL10n.upload_failed, 'GENERIC_ERROR': pluploadL10n.upload_failed,
'IO_ERROR': pluploadL10n.io_error, 'IO_ERROR': pluploadL10n.io_error,
'HTTP_ERROR': pluploadL10n.http_error, 'HTTP_ERROR': pluploadL10n.http_error,
'SECURITY_ERROR': pluploadL10n.security_error 'SECURITY_ERROR': pluploadL10n.security_error,
'FILE_SIZE_ERROR': function( file ) {
return pluploadL10n.file_exceeds_size_limit.replace('%s', file.name);
}
}; };
$.extend( Uploader.prototype, { $.extend( Uploader.prototype, {