Better display handling of error messages during swfupload uploading. Fixes #12225
git-svn-id: http://svn.automattic.com/wordpress/trunk@14816 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0c850182dc
commit
0821c7163b
|
@ -44,15 +44,17 @@ check_admin_referer('media-form');
|
|||
|
||||
$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
|
||||
if ( is_wp_error($id) ) {
|
||||
echo '<div id="media-upload-error">'.esc_html($id->get_error_message()).'</div>';
|
||||
echo '<div class="error-div">
|
||||
<a class="dismiss" href="#" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">' . __('Dismiss') . '</a>
|
||||
<strong>' . sprintf(__('“%s” has failed to upload due to an error'), esc_html($_FILES['async-upload']['name']) ) . '</strong><br />' .
|
||||
esc_html($id->get_error_message()) . '</div>';
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( $_REQUEST['short'] ) {
|
||||
// short form response - attachment ID only
|
||||
echo $id;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// long form response - big chunk o html
|
||||
$type = $_REQUEST['type'];
|
||||
echo apply_filters("async_upload_{$type}", $id);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -145,10 +145,15 @@ function prepareMediaItemInit(fileObj) {
|
|||
}
|
||||
|
||||
function itemAjaxError(id, html) {
|
||||
var error = jQuery('#media-item-error' + id);
|
||||
var item = jQuery('#media-item-' + id);
|
||||
var filename = jQuery('.filename', item).text();
|
||||
|
||||
error.html('<div class="file-error"><button type="button" id="dismiss-'+id+'" class="button dismiss">'+swfuploadL10n.dismiss+'</button>'+html+'</div>');
|
||||
jQuery('#dismiss-'+id).click(function(){jQuery(this).parents('.file-error').slideUp(200, function(){jQuery(this).empty();})});
|
||||
item.html('<div class="error-div">'
|
||||
+ '<a class="dismiss" href="#">' + swfuploadL10n.dismiss + '</a>'
|
||||
+ '<strong>' + swfuploadL10n.error_uploading.replace('%s', filename) + '</strong><br />'
|
||||
+ html
|
||||
+ '</div>');
|
||||
item.find('a.dismiss').click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
|
||||
}
|
||||
|
||||
function deleteSuccess(data, textStatus) {
|
||||
|
@ -242,8 +247,15 @@ function wpQueueError(message) {
|
|||
|
||||
// file-specific message
|
||||
function wpFileError(fileObj, message) {
|
||||
jQuery('#media-item-' + fileObj.id + ' .filename').after('<div class="file-error"><button type="button" id="dismiss-' + fileObj.id + '" class="button dismiss">'+swfuploadL10n.dismiss+'</button>'+message+'</div>').siblings('.toggle').remove();
|
||||
jQuery('#dismiss-' + fileObj.id).click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
|
||||
var item = jQuery('#media-item-' + fileObj.id);
|
||||
var filename = jQuery('.filename', item).text();
|
||||
|
||||
item.html('<div class="error-div">'
|
||||
+ '<a class="dismiss" href="#">' + swfuploadL10n.dismiss + '</a>'
|
||||
+ '<strong>' + swfuploadL10n.error_uploading.replace('%s', filename) + '</strong><br />'
|
||||
+ message
|
||||
+ '</div>');
|
||||
item.find('a.dismiss').click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
|
||||
}
|
||||
|
||||
function fileQueueError(fileObj, error_code, message) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -190,7 +190,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
$scripts->add( 'swfupload-all', '/wp-includes/js/swfupload/swfupload-all.js', array(), '2201');
|
||||
}
|
||||
|
||||
$scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20100106');
|
||||
$scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array('swfupload-all', 'jquery'), '2201-20100523');
|
||||
$max_upload_size = ( (int) ( $max_up = @ini_get('upload_max_filesize') ) < (int) ( $max_post = @ini_get('post_max_size') ) ) ? $max_up : $max_post;
|
||||
if ( empty($max_upload_size) )
|
||||
$max_upload_size = __('not configured');
|
||||
|
@ -212,7 +212,8 @@ function wp_default_scripts( &$scripts ) {
|
|||
'dismiss' => __('Dismiss'),
|
||||
'crunching' => __('Crunching…'),
|
||||
'deleted' => __('moved to the trash.'),
|
||||
'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};'
|
||||
'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};',
|
||||
'error_uploading' => __('“%s” has failed to upload due to an error')
|
||||
) );
|
||||
|
||||
$scripts->add( 'comment-reply', "/wp-includes/js/comment-reply$suffix.js", false, '20090102');
|
||||
|
@ -434,7 +435,7 @@ function wp_default_styles( &$styles ) {
|
|||
// Any rtl stylesheets that don't have a .dev version for ltr
|
||||
$no_suffix = array( 'farbtastic' );
|
||||
|
||||
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20100521' );
|
||||
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20100523' );
|
||||
|
||||
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20100219' );
|
||||
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
|
||||
|
|
Loading…
Reference in New Issue