Ticket #39553: 39553.diff
File 39553.diff, 6.4 KB (added by , 8 years ago) |
---|
-
src/wp-admin/includes/media.php
1848 1848 1849 1849 $post_params = array( 1850 1850 "post_id" => $post_id, 1851 "_wpnonce" => wp_create_nonce(' media-form'),1851 "_wpnonce" => wp_create_nonce('wp_rest'), 1852 1852 "type" => $_type, 1853 1853 "tab" => $_tab, 1854 1854 "short" => "1", … … 1869 1869 'browse_button' => 'plupload-browse-button', 1870 1870 'container' => 'plupload-upload-ui', 1871 1871 'drop_element' => 'drag-drop-area', 1872 'file_data_name' => ' async-upload',1873 'url' => $upload_action_url,1872 'file_data_name' => 'file', 1873 'url' => rest_url( '/wp/v2/media' ), 1874 1874 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ), 1875 1875 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ), 1876 1876 'filters' => array( -
src/wp-includes/js/plupload/handlers.js
482 482 }); 483 483 484 484 uploader.bind('FileUploaded', function(up, file, response) { 485 uploadSuccess(file, response.response); 485 var data = JSON.parse( response.response ); 486 uploadSuccess( file, '' + data.id ); 486 487 }); 487 488 488 489 uploader.bind('UploadComplete', function() { -
src/wp-includes/js/plupload/wp-plupload.js
259 259 * @return {mixed} 260 260 */ 261 261 this.uploader.bind( 'FileUploaded', function( up, file, response ) { 262 var complete ;262 var complete, attachmentData, status = response.status, mimeType, size, sizeData; 263 263 264 264 try { 265 265 response = JSON.parse( response.response ); … … 267 267 return error( pluploadL10n.default_error, e, file ); 268 268 } 269 269 270 if ( ! _.isObject( response ) || _.isUndefined( response. success) )270 if ( ! _.isObject( response ) || _.isUndefined( response.id ) ) 271 271 return error( pluploadL10n.default_error, null, file ); 272 else if ( ! response.success)273 return error( response. data && response.data.message, response.data, file );272 else if ( status !== 201 ) 273 return error( response.message, response, file ); 274 274 275 275 _.each(['file','loaded','size','percent'], function( key ) { 276 276 file.attachment.unset( key ); 277 277 }); 278 278 279 file.attachment.set( _.extend( response.data, { uploading: false }) ); 280 wp.media.model.Attachment.get( response.data.id, file.attachment ); 279 // Convert new-style object to old-style. 280 mimeType = response.mime_type.indexOf('/') >= 0 ? response.mime_type.split('/') : [ response.mime_type, '' ]; 281 attachmentData = { 282 id : response.id, 283 title : response.title.raw, 284 filename : response.media_details.file.split('/').slice().pop(), 285 url : response.source_url, 286 link : response.link, 287 alt : response.alt_text, 288 author : response.author, 289 authorName : '', // $author->display_name, 290 description : response.description.raw, 291 caption : response.caption.raw, 292 name : response.slug, 293 status : response.status, 294 uploadedTo : response.parent, 295 date : wp.api.utils.parseISO8601( response.date_gmt ), 296 modified : wp.api.utils.parseISO8601( response.modified_gmt ), 297 menuOrder : 0, //$attachment->menu_order, 298 mime : response.mime_type, 299 type : mimeType[0], 300 subtype : mimeType[1], 301 icon : '',//wp_mime_type_icon( $attachment->ID ), 302 dateFormatted: response.post_date, // mysql2date( __( 'F j, Y' ), $attachment->post_date ), 303 nonces : { 304 update : this.getOption( 'multipart_params' )._wpnonce, // wp_create_nonce( 'update-post_' . $attachment->ID ) 305 delete : this.getOption( 'multipart_params' )._wpnonce, 306 edit : this.getOption( 'multipart_params' )._wpnonce, // wp_create_nonce( 'image_editor-' . $attachment->ID ) 307 }, 308 editLink : false, // get_edit_post_link( $attachment->ID, 'raw' ) 309 meta : false, 310 }; 311 if ( response.media_details.sizes ) { 312 attachmentData.sizes = {}; 313 for (size in response.media_details.sizes) { 314 if (response.media_details.sizes.hasOwnProperty(size)) { 315 sizeData = response.media_details[ size ]; 316 attachmentData.sizes[ size ] = { 317 height: sizeData.height, 318 width: sizeData.width, 319 url: sizeData.source_url, 320 orientation: sizeData.height > sizeData.width ? 'portrait' : 'landscape', 321 }; 322 } 323 } 324 } 325 if ( response.media_details.height ) { 326 attachmentData.height = response.media_details.height; 327 } 328 if ( response.media_details.width ) { 329 attachmentData.width = response.media_details.width; 330 } 331 if ( response.media_details.image_meta ) { 332 attachmentData.meta = response.media_details.image_meta; 333 } 281 334 335 file.attachment.set( _.extend( attachmentData, { uploading: false }) ); 336 wp.media.model.Attachment.get( attachmentData.id, file.attachment ); 337 282 338 complete = Uploader.queue.all( function( attachment ) { 283 339 return ! attachment.get('uploading'); 284 340 }); -
src/wp-includes/media.php
2983 2983 2984 2984 $defaults = array( 2985 2985 'runtimes' => 'html5,flash,silverlight,html4', 2986 'file_data_name' => ' async-upload', // key passed to $_FILE.2987 'url' => admin_url( 'async-upload.php', 'relative' ),2986 'file_data_name' => 'file', // key passed to $_FILE. 2987 'url' => rest_url( '/wp/v2/media' ), 2988 2988 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ), 2989 2989 'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ), 2990 2990 'filters' => array( … … 3022 3022 * @param array $params Default Plupload parameters array. 3023 3023 */ 3024 3024 $params = apply_filters( 'plupload_default_params', $params ); 3025 $params['_wpnonce'] = wp_create_nonce( ' media-form' );3025 $params['_wpnonce'] = wp_create_nonce( 'wp_rest' ); 3026 3026 $defaults['multipart_params'] = $params; 3027 3027 3028 3028 $settings = array(