Workaround response truncation by reducing size of response after uploading with flash uploader. Props tellyworth. fixes #6713
git-svn-id: https://develop.svn.wordpress.org/trunk@7682 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
307c2ac093
commit
a58816e2ab
@ -20,13 +20,26 @@ header('Content-Type: text/plain');
|
|||||||
if ( !current_user_can('upload_files') )
|
if ( !current_user_can('upload_files') )
|
||||||
wp_die(__('You do not have permission to upload files.'));
|
wp_die(__('You do not have permission to upload files.'));
|
||||||
|
|
||||||
|
// just fetch the detail form for that attachment
|
||||||
|
if ( ($id = intval($_REQUEST['attachment_id'])) && $_REQUEST['fetch'] ) {
|
||||||
|
echo get_media_item($id);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
|
$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
|
||||||
if (is_wp_error($id)) {
|
if (is_wp_error($id)) {
|
||||||
echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
|
echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = $_REQUEST['type'];
|
if ( $_REQUEST['short'] ) {
|
||||||
echo apply_filters("async_upload_{$type}", $id);
|
// short form response - attachment ID only
|
||||||
|
echo $id;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// long form response - big chunk o html
|
||||||
|
$type = $_REQUEST['type'];
|
||||||
|
echo apply_filters("async_upload_{$type}", $id);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -804,7 +804,8 @@ jQuery(function($){
|
|||||||
"post_id" : "<?php echo $post_id; ?>",
|
"post_id" : "<?php echo $post_id; ?>",
|
||||||
"auth_cookie" : "<?php echo $_COOKIE[AUTH_COOKIE]; ?>",
|
"auth_cookie" : "<?php echo $_COOKIE[AUTH_COOKIE]; ?>",
|
||||||
"type" : "<?php echo $type; ?>",
|
"type" : "<?php echo $type; ?>",
|
||||||
"tab" : "<?php echo $tab; ?>"
|
"tab" : "<?php echo $tab; ?>",
|
||||||
|
"short" : "1"
|
||||||
},
|
},
|
||||||
file_size_limit : "<?php echo wp_max_upload_size(); ?>b",
|
file_size_limit : "<?php echo wp_max_upload_size(); ?>b",
|
||||||
swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available
|
swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available
|
||||||
|
@ -35,8 +35,18 @@ function prepareMediaItem(fileObj, serverData) {
|
|||||||
jQuery('#media-item-' + fileObj.id + ' .bar').remove();
|
jQuery('#media-item-' + fileObj.id + ' .bar').remove();
|
||||||
jQuery('#media-item-' + fileObj.id + ' .progress').hide();
|
jQuery('#media-item-' + fileObj.id + ' .progress').hide();
|
||||||
|
|
||||||
// Append the HTML returned by the server -- thumbnail and form inputs
|
// Old style: Append the HTML returned by the server -- thumbnail and form inputs
|
||||||
|
if ( isNaN(serverData) || !serverData ) {
|
||||||
jQuery('#media-item-' + fileObj.id).append(serverData);
|
jQuery('#media-item-' + fileObj.id).append(serverData);
|
||||||
|
prepareMediaItemInit(fileObj);
|
||||||
|
}
|
||||||
|
// New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
|
||||||
|
else {
|
||||||
|
jQuery('#media-item-' + fileObj.id).load('async-upload.php', {attachment_id:serverData, fetch:1}, function(){prepareMediaItemInit(fileObj);updateMediaForm()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepareMediaItemInit(fileObj) {
|
||||||
|
|
||||||
// Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
|
// Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
|
||||||
jQuery('#media-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail toggle').prependTo('#media-item-' + fileObj.id);
|
jQuery('#media-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail toggle').prependTo('#media-item-' + fileObj.id);
|
||||||
|
@ -87,7 +87,7 @@ class WP_Scripts {
|
|||||||
'is_lighttpd_before_150' => is_lighttpd_before_150(),
|
'is_lighttpd_before_150' => is_lighttpd_before_150(),
|
||||||
) );
|
) );
|
||||||
$this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2');
|
$this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2');
|
||||||
$this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080331');
|
$this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2-20080407');
|
||||||
// these error messages came from the sample swfupload js, they might need changing.
|
// these error messages came from the sample swfupload js, they might need changing.
|
||||||
$this->localize( 'swfupload-handlers', 'swfuploadL10n', array(
|
$this->localize( 'swfupload-handlers', 'swfuploadL10n', array(
|
||||||
'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
|
'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
|
||||||
|
Loading…
Reference in New Issue
Block a user