2014-02-27 15:01:16 -05:00
|
|
|
/* global plupload, pluploadL10n, ajaxurl, post_id, wpUploaderInit, deleteUserSetting, setUserSetting, getUserSetting, shortform */
|
2012-08-22 20:04:18 -04:00
|
|
|
var topWin = window.dialogArguments || opener || parent || top, uploader, uploader_init;
|
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// Progress and success handlers for media multi uploads.
|
2019-09-03 21:11:54 -04:00
|
|
|
function fileQueued( fileObj ) {
|
2020-01-28 19:45:18 -05:00
|
|
|
// Get rid of unused form.
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '.media-blank' ).remove();
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
var items = jQuery( '#media-items' ).children(), postid = post_id || 0;
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// Collapse a single item.
|
2012-08-22 20:04:18 -04:00
|
|
|
if ( items.length == 1 ) {
|
2019-09-03 21:11:54 -04:00
|
|
|
items.removeClass( 'open' ).find( '.slidetoggle' ).slideUp( 200 );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
2020-01-28 19:45:18 -05:00
|
|
|
// Create a progress bar containing the filename.
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '<div class="media-item">' )
|
2013-06-20 23:44:48 -04:00
|
|
|
.attr( 'id', 'media-item-' + fileObj.id )
|
2019-09-03 21:11:54 -04:00
|
|
|
.addClass( 'child-of-' + postid )
|
|
|
|
.append( '<div class="progress"><div class="percent">0%</div><div class="bar"></div></div>',
|
|
|
|
jQuery( '<div class="filename original">' ).text( ' ' + fileObj.name ) )
|
|
|
|
.appendTo( jQuery( '#media-items' ) );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// Disable submit.
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '#insert-gallery' ).prop( 'disabled', true );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function uploadStart() {
|
|
|
|
try {
|
|
|
|
if ( typeof topWin.tb_remove != 'undefined' )
|
2019-09-03 21:11:54 -04:00
|
|
|
topWin.jQuery( '#TB_overlay' ).unbind( 'click', topWin.tb_remove );
|
|
|
|
} catch( e ){}
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
function uploadProgress( up, file ) {
|
|
|
|
var item = jQuery( '#media-item-' + file.id );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '.bar', item ).width( ( 200 * file.loaded ) / file.size );
|
|
|
|
jQuery( '.percent', item ).html( file.percent + '%' );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// Check to see if a large file failed to upload.
|
2014-02-27 15:01:16 -05:00
|
|
|
function fileUploading( up, file ) {
|
|
|
|
var hundredmb = 100 * 1024 * 1024,
|
|
|
|
max = parseInt( up.settings.max_file_size, 10 );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
if ( max > hundredmb && file.size > hundredmb ) {
|
2014-02-27 15:01:16 -05:00
|
|
|
setTimeout( function() {
|
2020-01-28 19:45:18 -05:00
|
|
|
if ( file.status < 3 && file.loaded === 0 ) { // Not uploading.
|
2014-02-27 15:01:16 -05:00
|
|
|
wpFileError( file, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) );
|
2020-01-28 19:45:18 -05:00
|
|
|
up.stop(); // Stop the whole queue.
|
2014-02-27 15:01:16 -05:00
|
|
|
up.removeFile( file );
|
2020-01-28 19:45:18 -05:00
|
|
|
up.start(); // Restart the queue.
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
2020-01-28 19:45:18 -05:00
|
|
|
}, 10000 ); // Wait for 10 seconds for the file to start uploading.
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateMediaForm() {
|
2019-09-03 21:11:54 -04:00
|
|
|
var items = jQuery( '#media-items' ).children();
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// Just one file, no need for collapsible part.
|
2012-08-22 20:04:18 -04:00
|
|
|
if ( items.length == 1 ) {
|
2019-09-03 21:11:54 -04:00
|
|
|
items.addClass( 'open' ).find( '.slidetoggle' ).show();
|
|
|
|
jQuery( '.insert-gallery' ).hide();
|
2012-08-22 20:04:18 -04:00
|
|
|
} else if ( items.length > 1 ) {
|
2019-09-03 21:11:54 -04:00
|
|
|
items.removeClass( 'open' );
|
2014-02-24 13:08:16 -05:00
|
|
|
// Only show Gallery/Playlist buttons when there are at least two files.
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '.insert-gallery' ).show();
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Only show Save buttons when there is at least one file.
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( items.not( '.media-blank' ).length > 0 )
|
|
|
|
jQuery( '.savebutton' ).show();
|
2012-08-22 20:04:18 -04:00
|
|
|
else
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '.savebutton' ).hide();
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
function uploadSuccess( fileObj, serverData ) {
|
|
|
|
var item = jQuery( '#media-item-' + fileObj.id );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// On success serverData should be numeric,
|
|
|
|
// fix bug in html4 runtime returning the serverData wrapped in a <pre> tag.
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( typeof serverData === 'string' ) {
|
|
|
|
serverData = serverData.replace( /^<pre>(\d+)<\/pre>$/, '$1' );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// If async-upload returned an error message, place it in the media item div and return.
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( /media-upload-error|error-div/.test( serverData ) ) {
|
|
|
|
item.html( serverData );
|
|
|
|
return;
|
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
item.find( '.percent' ).html( pluploadL10n.crunching );
|
|
|
|
|
|
|
|
prepareMediaItem( fileObj, serverData );
|
2012-08-22 20:04:18 -04:00
|
|
|
updateMediaForm();
|
|
|
|
|
|
|
|
// Increment the counter.
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( post_id && item.hasClass( 'child-of-' + post_id ) ) {
|
|
|
|
jQuery( '#attachments-count' ).text( 1 * jQuery( '#attachments-count' ).text() + 1 );
|
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2014-02-27 15:01:16 -05:00
|
|
|
function setResize( arg ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
if ( arg ) {
|
2014-02-27 15:01:16 -05:00
|
|
|
if ( window.resize_width && window.resize_height ) {
|
|
|
|
uploader.settings.resize = {
|
|
|
|
enabled: true,
|
|
|
|
width: window.resize_width,
|
|
|
|
height: window.resize_height,
|
|
|
|
quality: 100
|
|
|
|
};
|
|
|
|
} else {
|
2012-08-22 20:04:18 -04:00
|
|
|
uploader.settings.multipart_params.image_resize = true;
|
2014-02-27 15:01:16 -05:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
} else {
|
2014-02-27 15:01:16 -05:00
|
|
|
delete( uploader.settings.multipart_params.image_resize );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
function prepareMediaItem( fileObj, serverData ) {
|
|
|
|
var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery( '#media-item-' + fileObj.id );
|
2012-11-21 08:05:44 -05:00
|
|
|
if ( f == 2 && shortform > 2 )
|
|
|
|
f = shortform;
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
try {
|
|
|
|
if ( typeof topWin.tb_remove != 'undefined' )
|
2019-09-03 21:11:54 -04:00
|
|
|
topWin.jQuery( '#TB_overlay' ).click( topWin.tb_remove );
|
|
|
|
} catch( e ){}
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
if ( isNaN( serverData ) || !serverData ) {
|
|
|
|
// Old style: Append the HTML returned by the server -- thumbnail and form inputs.
|
2019-09-03 21:11:54 -04:00
|
|
|
item.append( serverData );
|
|
|
|
prepareMediaItemInit( fileObj );
|
2020-01-28 19:45:18 -05:00
|
|
|
} else {
|
|
|
|
// New style: server data is just the attachment ID, fetch the thumbnail and form html from the server.
|
2019-09-03 21:11:54 -04:00
|
|
|
item.load( 'async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit( fileObj );updateMediaForm();});
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
function prepareMediaItemInit( fileObj ) {
|
|
|
|
var item = jQuery( '#media-item-' + fileObj.id );
|
2020-01-28 19:45:18 -05:00
|
|
|
// Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename.
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '.thumbnail', item ).clone().attr( 'class', 'pinkynail toggle' ).prependTo( item );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// Replace the original filename with the new (unique) one assigned during upload.
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '.filename.original', item ).replaceWith( jQuery( '.filename.new', item ) );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2020-06-25 08:43:07 -04:00
|
|
|
// Bind Ajax to the new Delete button.
|
2021-10-28 13:50:58 -04:00
|
|
|
jQuery( 'a.delete', item ).on( 'click', function(){
|
2020-01-28 19:45:18 -05:00
|
|
|
// Tell the server to delete it. TODO: Handle exceptions.
|
2012-08-22 20:04:18 -04:00
|
|
|
jQuery.ajax({
|
|
|
|
url: ajaxurl,
|
|
|
|
type: 'post',
|
|
|
|
success: deleteSuccess,
|
|
|
|
error: deleteError,
|
|
|
|
id: fileObj.id,
|
|
|
|
data: {
|
2019-09-03 21:11:54 -04:00
|
|
|
id : this.id.replace(/[^0-9]/g, '' ),
|
2012-08-22 20:04:18 -04:00
|
|
|
action : 'trash-post',
|
2019-09-03 21:11:54 -04:00
|
|
|
_ajax_nonce : this.href.replace(/^.*wpnonce=/,'' )
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2020-06-25 08:43:07 -04:00
|
|
|
// Bind Ajax to the new Undo button.
|
2021-10-28 13:50:58 -04:00
|
|
|
jQuery( 'a.undo', item ).on( 'click', function(){
|
2020-01-28 19:45:18 -05:00
|
|
|
// Tell the server to untrash it. TODO: Handle exceptions.
|
2012-08-22 20:04:18 -04:00
|
|
|
jQuery.ajax({
|
|
|
|
url: ajaxurl,
|
|
|
|
type: 'post',
|
|
|
|
id: fileObj.id,
|
|
|
|
data: {
|
2019-09-03 21:11:54 -04:00
|
|
|
id : this.id.replace(/[^0-9]/g,'' ),
|
2012-08-22 20:04:18 -04:00
|
|
|
action: 'untrash-post',
|
2019-09-03 21:11:54 -04:00
|
|
|
_ajax_nonce: this.href.replace(/^.*wpnonce=/,'' )
|
2012-08-22 20:04:18 -04:00
|
|
|
},
|
2013-11-15 00:56:09 -05:00
|
|
|
success: function( ){
|
|
|
|
var type,
|
2019-09-03 21:11:54 -04:00
|
|
|
item = jQuery( '#media-item-' + fileObj.id );
|
2014-02-24 15:49:14 -05:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( type = jQuery( '#type-of-' + fileObj.id ).val() )
|
|
|
|
jQuery( '#' + type + '-counter' ).text( jQuery( '#' + type + '-counter' ).text()-0+1 );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( post_id && item.hasClass( 'child-of-'+post_id ) )
|
|
|
|
jQuery( '#attachments-count' ).text( jQuery( '#attachments-count' ).text()-0+1 );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '.filename .trashnotice', item ).remove();
|
|
|
|
jQuery( '.filename .title', item ).css( 'font-weight','normal' );
|
|
|
|
jQuery( 'a.undo', item ).addClass( 'hidden' );
|
|
|
|
jQuery( '.menu_order_input', item ).show();
|
|
|
|
item.css( {backgroundColor:'#ceb'} ).animate( {backgroundColor: '#fff'}, { queue: false, duration: 500, complete: function(){ jQuery( this ).css({backgroundColor:''}); } }).removeClass( 'undo' );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// Open this item if it says to start open (e.g. to display an error).
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '#media-item-' + fileObj.id + '.startopen' ).removeClass( 'startopen' ).addClass( 'open' ).find( 'slidetoggle' ).fadeIn();
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// Generic error message.
|
2019-09-03 21:11:54 -04:00
|
|
|
function wpQueueError( message ) {
|
|
|
|
jQuery( '#media-upload-error' ).show().html( '<div class="error"><p>' + message + '</p></div>' );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// File-specific error messages.
|
2019-09-03 21:11:54 -04:00
|
|
|
function wpFileError( fileObj, message ) {
|
|
|
|
itemAjaxError( fileObj.id, message );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
function itemAjaxError( id, message ) {
|
|
|
|
var item = jQuery( '#media-item-' + id ), filename = item.find( '.filename' ).text(), last_err = item.data( 'last-err' );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
if ( last_err == id ) // Prevent firing an error for the same file twice.
|
2012-08-22 20:04:18 -04:00
|
|
|
return;
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
item.html( '<div class="error-div">' +
|
2019-11-03 12:09:02 -05:00
|
|
|
'<a class="dismiss" href="#">' + pluploadL10n.dismiss + '</a>' +
|
|
|
|
'<strong>' + pluploadL10n.error_uploading.replace( '%s', jQuery.trim( filename )) + '</strong> ' +
|
|
|
|
message +
|
|
|
|
'</div>' ).data( 'last-err', id );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
function deleteSuccess( data ) {
|
2013-11-15 00:56:09 -05:00
|
|
|
var type, id, item;
|
2012-08-22 20:04:18 -04:00
|
|
|
if ( data == '-1' )
|
2019-09-03 21:11:54 -04:00
|
|
|
return itemAjaxError( this.id, 'You do not have permission. Has your session expired?' );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
if ( data == '0' )
|
2019-09-03 21:11:54 -04:00
|
|
|
return itemAjaxError( this.id, 'Could not be deleted. Has it been deleted already?' );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2013-11-15 00:56:09 -05:00
|
|
|
id = this.id;
|
2019-09-03 21:11:54 -04:00
|
|
|
item = jQuery( '#media-item-' + id );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
// Decrement the counters.
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( type = jQuery( '#type-of-' + id ).val() )
|
|
|
|
jQuery( '#' + type + '-counter' ).text( jQuery( '#' + type + '-counter' ).text() - 1 );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( post_id && item.hasClass( 'child-of-'+post_id ) )
|
|
|
|
jQuery( '#attachments-count' ).text( jQuery( '#attachments-count' ).text() - 1 );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( jQuery( 'form.type-form #media-items' ).children().length == 1 && jQuery( '.hidden', '#media-items' ).length > 0 ) {
|
|
|
|
jQuery( '.toggle' ).toggle();
|
|
|
|
jQuery( '.slidetoggle' ).slideUp( 200 ).siblings().removeClass( 'hidden' );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Vanish it.
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '.toggle', item ).toggle();
|
|
|
|
jQuery( '.slidetoggle', item ).slideUp( 200 ).siblings().removeClass( 'hidden' );
|
|
|
|
item.css( {backgroundColor:'#faa'} ).animate( {backgroundColor:'#f4f4f4'}, {queue:false, duration:500} ).addClass( 'undo' );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '.filename:empty', item ).remove();
|
|
|
|
jQuery( '.filename .title', item ).css( 'font-weight','bold' );
|
|
|
|
jQuery( '.filename', item ).append( '<span class="trashnotice"> ' + pluploadL10n.deleted + ' </span>' ).siblings( 'a.toggle' ).hide();
|
|
|
|
jQuery( '.filename', item ).append( jQuery( 'a.undo', item ).removeClass( 'hidden' ) );
|
|
|
|
jQuery( '.menu_order_input', item ).hide();
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-15 00:56:09 -05:00
|
|
|
function deleteError() {
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function uploadComplete() {
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '#insert-gallery' ).prop( 'disabled', false );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
function switchUploader( s ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
if ( s ) {
|
2019-09-03 21:11:54 -04:00
|
|
|
deleteUserSetting( 'uploader' );
|
|
|
|
jQuery( '.media-upload-form' ).removeClass( 'html-uploader' );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( typeof( uploader ) == 'object' )
|
2012-08-22 20:04:18 -04:00
|
|
|
uploader.refresh();
|
|
|
|
} else {
|
2020-01-28 19:45:18 -05:00
|
|
|
setUserSetting( 'uploader', '1' ); // 1 == html uploader.
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '.media-upload-form' ).addClass( 'html-uploader' );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
function uploadError( fileObj, errorCode, message, up ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
var hundredmb = 100 * 1024 * 1024, max;
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
switch ( errorCode ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
case plupload.FAILED:
|
2019-09-03 21:11:54 -04:00
|
|
|
wpFileError( fileObj, pluploadL10n.upload_failed );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case plupload.FILE_EXTENSION_ERROR:
|
2019-09-03 21:11:54 -04:00
|
|
|
wpFileExtensionError( up, fileObj, pluploadL10n.invalid_filetype );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case plupload.FILE_SIZE_ERROR:
|
2019-09-03 21:11:54 -04:00
|
|
|
uploadSizeError( up, fileObj );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case plupload.IMAGE_FORMAT_ERROR:
|
2019-09-03 21:11:54 -04:00
|
|
|
wpFileError( fileObj, pluploadL10n.not_an_image );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case plupload.IMAGE_MEMORY_ERROR:
|
2019-09-03 21:11:54 -04:00
|
|
|
wpFileError( fileObj, pluploadL10n.image_memory_exceeded );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case plupload.IMAGE_DIMENSIONS_ERROR:
|
2019-09-03 21:11:54 -04:00
|
|
|
wpFileError( fileObj, pluploadL10n.image_dimensions_exceeded );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case plupload.GENERIC_ERROR:
|
2019-09-03 21:11:54 -04:00
|
|
|
wpQueueError( pluploadL10n.upload_failed );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case plupload.IO_ERROR:
|
2019-09-03 21:11:54 -04:00
|
|
|
max = parseInt( up.settings.filters.max_file_size, 10 );
|
|
|
|
|
|
|
|
if ( max > hundredmb && fileObj.size > hundredmb ) {
|
|
|
|
wpFileError( fileObj, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) );
|
|
|
|
} else {
|
|
|
|
wpQueueError( pluploadL10n.io_error );
|
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
break;
|
|
|
|
case plupload.HTTP_ERROR:
|
2019-09-03 21:11:54 -04:00
|
|
|
wpQueueError( pluploadL10n.http_error );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case plupload.INIT_ERROR:
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '.media-upload-form' ).addClass( 'html-uploader' );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
|
|
|
case plupload.SECURITY_ERROR:
|
2019-09-03 21:11:54 -04:00
|
|
|
wpQueueError( pluploadL10n.security_error );
|
2012-08-22 20:04:18 -04:00
|
|
|
break;
|
2019-11-03 12:09:02 -05:00
|
|
|
/* case plupload.UPLOAD_ERROR.UPLOAD_STOPPED:
|
|
|
|
case plupload.UPLOAD_ERROR.FILE_CANCELLED:
|
|
|
|
jQuery( '#media-item-' + fileObj.id ).remove();
|
|
|
|
break;*/
|
2012-08-22 20:04:18 -04:00
|
|
|
default:
|
2019-09-03 21:11:54 -04:00
|
|
|
wpFileError( fileObj, pluploadL10n.default_error );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-16 13:58:41 -04:00
|
|
|
function uploadSizeError( up, file ) {
|
|
|
|
var message, errorDiv;
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
message = pluploadL10n.file_exceeds_size_limit.replace( '%s', file.name );
|
2017-05-16 13:58:41 -04:00
|
|
|
|
|
|
|
// Construct the error div.
|
|
|
|
errorDiv = jQuery( '<div />' )
|
|
|
|
.attr( {
|
|
|
|
'id': 'media-item-' + file.id,
|
|
|
|
'class': 'media-item error'
|
|
|
|
} )
|
|
|
|
.append(
|
|
|
|
jQuery( '<p />' )
|
|
|
|
.text( message )
|
|
|
|
);
|
|
|
|
|
|
|
|
// Append the error.
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '#media-items' ).append( errorDiv );
|
|
|
|
up.removeFile( file );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
|
2016-06-16 11:39:28 -04:00
|
|
|
function wpFileExtensionError( up, file, message ) {
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( '#media-items' ).append( '<div id="media-item-' + file.id + '" class="media-item error"><p>' + message + '</p></div>' );
|
|
|
|
up.removeFile( file );
|
2016-06-16 11:39:28 -04:00
|
|
|
}
|
|
|
|
|
2021-05-25 21:40:58 -04:00
|
|
|
/**
|
|
|
|
* Copies the attachment URL to the clipboard.
|
|
|
|
*
|
|
|
|
* @since 5.8.0
|
|
|
|
*
|
|
|
|
* @param {MouseEvent} event A click event.
|
|
|
|
*
|
|
|
|
* @return {void}
|
|
|
|
*/
|
|
|
|
function copyAttachmentUploadURLClipboard() {
|
|
|
|
var clipboard = new ClipboardJS( '.copy-attachment-url' ),
|
2021-05-26 10:24:57 -04:00
|
|
|
successTimeout;
|
|
|
|
|
2021-05-25 21:40:58 -04:00
|
|
|
clipboard.on( 'success', function( event ) {
|
|
|
|
var triggerElement = jQuery( event.trigger ),
|
|
|
|
successElement = jQuery( '.success', triggerElement.closest( '.copy-to-clipboard-container' ) );
|
2021-05-26 10:24:57 -04:00
|
|
|
|
2021-05-25 21:40:58 -04:00
|
|
|
// Clear the selection and move focus back to the trigger.
|
|
|
|
event.clearSelection();
|
|
|
|
// Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680
|
|
|
|
triggerElement.trigger( 'focus' );
|
|
|
|
// Show success visual feedback.
|
|
|
|
clearTimeout( successTimeout );
|
|
|
|
successElement.removeClass( 'hidden' );
|
|
|
|
// Hide success visual feedback after 3 seconds since last success.
|
|
|
|
successTimeout = setTimeout( function() {
|
|
|
|
successElement.addClass( 'hidden' );
|
|
|
|
}, 3000 );
|
|
|
|
// Handle success audible feedback.
|
|
|
|
wp.a11y.speak( pluploadL10n.file_url_copied );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
jQuery( document ).ready( function( $ ) {
|
2021-05-25 21:40:58 -04:00
|
|
|
copyAttachmentUploadURLClipboard();
|
2019-09-03 21:11:54 -04:00
|
|
|
var tryAgainCount = {};
|
|
|
|
var tryAgain;
|
|
|
|
|
|
|
|
$( '.media-upload-form' ).bind( 'click.uploader', function( e ) {
|
|
|
|
var target = $( e.target ), tr, c;
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
if ( target.is( 'input[type="radio"]' ) ) { // Remember the last used image size and alignment.
|
2019-09-03 21:11:54 -04:00
|
|
|
tr = target.closest( 'tr' );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( tr.hasClass( 'align' ) )
|
|
|
|
setUserSetting( 'align', target.val() );
|
|
|
|
else if ( tr.hasClass( 'image-size' ) )
|
|
|
|
setUserSetting( 'imgsize', target.val() );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
} else if ( target.is( 'button.button' ) ) { // Remember the last used image link url.
|
2012-08-22 20:04:18 -04:00
|
|
|
c = e.target.className || '';
|
2019-09-03 21:11:54 -04:00
|
|
|
c = c.match( /url([^ '"]+)/ );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
if ( c && c[1] ) {
|
2019-09-03 21:11:54 -04:00
|
|
|
setUserSetting( 'urlbutton', c[1] );
|
|
|
|
target.siblings( '.urlfield' ).val( target.data( 'link-url' ) );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
2019-09-03 21:11:54 -04:00
|
|
|
} else if ( target.is( 'a.dismiss' ) ) {
|
|
|
|
target.parents( '.media-item' ).fadeOut( 200, function() {
|
|
|
|
$( this ).remove();
|
|
|
|
} );
|
2020-01-28 19:45:18 -05:00
|
|
|
} else if ( target.is( '.upload-flash-bypass a' ) || target.is( 'a.uploader-html' ) ) { // Switch uploader to html4.
|
2019-09-03 21:11:54 -04:00
|
|
|
$( '#media-items, p.submit, span.big-file-warning' ).css( 'display', 'none' );
|
|
|
|
switchUploader( 0 );
|
2012-08-22 20:04:18 -04:00
|
|
|
e.preventDefault();
|
2020-01-28 19:45:18 -05:00
|
|
|
} else if ( target.is( '.upload-html-bypass a' ) ) { // Switch uploader to multi-file.
|
2019-09-03 21:11:54 -04:00
|
|
|
$( '#media-items, p.submit, span.big-file-warning' ).css( 'display', '' );
|
|
|
|
switchUploader( 1 );
|
2012-08-22 20:04:18 -04:00
|
|
|
e.preventDefault();
|
2020-01-28 19:45:18 -05:00
|
|
|
} else if ( target.is( 'a.describe-toggle-on' ) ) { // Show.
|
2019-09-03 21:11:54 -04:00
|
|
|
target.parent().addClass( 'open' );
|
|
|
|
target.siblings( '.slidetoggle' ).fadeIn( 250, function() {
|
|
|
|
var S = $( window ).scrollTop(),
|
|
|
|
H = $( window ).height(),
|
|
|
|
top = $( this ).offset().top,
|
|
|
|
h = $( this ).height(),
|
|
|
|
b,
|
|
|
|
B;
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
if ( H && top && h ) {
|
|
|
|
b = top + h;
|
|
|
|
B = S + H;
|
|
|
|
|
|
|
|
if ( b > B ) {
|
|
|
|
if ( b - B < top - S )
|
2019-09-03 21:11:54 -04:00
|
|
|
window.scrollBy( 0, ( b - B ) + 10 );
|
2012-08-22 20:04:18 -04:00
|
|
|
else
|
2019-09-03 21:11:54 -04:00
|
|
|
window.scrollBy( 0, top - S - 40 );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
|
|
|
}
|
2019-09-03 21:11:54 -04:00
|
|
|
} );
|
|
|
|
|
2012-08-22 20:04:18 -04:00
|
|
|
e.preventDefault();
|
2020-01-28 19:45:18 -05:00
|
|
|
} else if ( target.is( 'a.describe-toggle-off' ) ) { // Hide.
|
2019-09-03 21:11:54 -04:00
|
|
|
target.siblings( '.slidetoggle' ).fadeOut( 250, function() {
|
|
|
|
target.parent().removeClass( 'open' );
|
|
|
|
} );
|
|
|
|
|
2012-08-22 20:04:18 -04:00
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
// Attempt to create image sub-sizes when an image was uploaded successfully
|
2019-10-21 18:44:03 -04:00
|
|
|
// but the server responded with an HTTP 5xx error.
|
2019-09-03 21:11:54 -04:00
|
|
|
tryAgain = function( up, error ) {
|
|
|
|
var file = error.file;
|
|
|
|
var times;
|
2019-10-03 17:02:00 -04:00
|
|
|
var id;
|
2019-09-03 21:11:54 -04:00
|
|
|
|
2019-10-03 17:02:00 -04:00
|
|
|
if ( ! error || ! error.responseHeaders ) {
|
|
|
|
wpQueueError( pluploadL10n.http_error_image );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
id = error.responseHeaders.match( /x-wp-upload-attachment-id:\s*(\d+)/i );
|
|
|
|
|
|
|
|
if ( id && id[1] ) {
|
|
|
|
id = id[1];
|
|
|
|
} else {
|
|
|
|
wpQueueError( pluploadL10n.http_error_image );
|
2019-09-03 21:11:54 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
times = tryAgainCount[ file.id ];
|
|
|
|
|
Media: enable generating multiple mime types for image uploads; specifically WebP versions for JPEG images by default.
This changeset adds the capability for core media uploads to generate sub sized images in more than a single mime type. The output formats for each mime type can be controlled through a filter. WebP is used as an additional output format for JPEG images by default to improve front end performance.
When generating additional mime types, only images which are smaller than the respective original are retained. By default, additional mime type images are only generated for the built-in core image sizes and any custom sizes that have opted in.
Image meta is updated with a new 'sources' array containing file details for each mime type. Each image size in the 'sizes' array also gets a new 'sources' array that contains the image file details for each mime type.
This change also increases image upload retries to accommodate additional image sizes. It also adds a `$mime_type` parameter to the `wp_get_missing_image_subsizes` function and filter.
This change adds three new filters to enable full control of secondary mime image generation and output:
* A new filter `wp_image_sizes_with_additional_mime_type_support` that filters the sizes that support secondary mime type output. Developers can use this to control the output of additional mime type sub-sized images on a per size basis.
* A new filter `wp_upload_image_mime_transforms` that filters the output mime types for a given input mime type. Developers can use this to control generation of additional mime types for a given input mime type or even override the original mime type.
* A new filter `wp_content_image_mimes` which controls image mime type output selection and order for frontend content. Developers can use this to control the mime type output preference order for content images. Content images inserted from the media library will use the available image versions based on the order from this filter.
Thanks to the many contributors who helped develop, test and give feedback on this feature.
A haiku to summarize:
Upload a JPEG
Images of all sizes
Output as WebPs
Props flixos90, MatthiasReinholz, studiolxv, markhowellsmead, eatingrules, pbiron, mukesh27, joegrainger, mehulkaklotar, tweetythierry, akshitsethi, peterwilsoncc, eugenemanuilov, mitogh, shetheliving, clarkeemily, codekraft, mikeschroder, clorith, kasparsd, spacedmonkey, trevorpfromsandee, jb510, scofennellgmailcom, seedsca, cagsmith, karinclimber, dainemawer, baxbridge, grapplerulrich, sobatkras, chynnabenton, tonylocalword, barneydavey, kwillmorth, garymatthews919, olliejones, imarkinteractive, jeffpaul, feastdesignco, webbeetle, masteradhoc.
See #55443.
Built from https://develop.svn.wordpress.org/trunk@53751
git-svn-id: http://core.svn.wordpress.org/trunk@53310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-21 14:03:13 -04:00
|
|
|
if ( times && times > 8 ) {
|
2020-01-28 19:45:18 -05:00
|
|
|
/*
|
|
|
|
* The file may have been uploaded and attachment post created,
|
|
|
|
* but post-processing and resizing failed...
|
|
|
|
* Do a cleanup then tell the user to scale down the image and upload it again.
|
|
|
|
*/
|
2019-09-03 21:11:54 -04:00
|
|
|
$.ajax({
|
|
|
|
type: 'post',
|
|
|
|
url: ajaxurl,
|
|
|
|
dataType: 'json',
|
|
|
|
data: {
|
|
|
|
action: 'media-create-image-subsizes',
|
2019-10-03 17:02:00 -04:00
|
|
|
_wpnonce: wpUploaderInit.multipart_params._wpnonce,
|
|
|
|
attachment_id: id,
|
2019-11-03 12:09:02 -05:00
|
|
|
_wp_upload_failed_cleanup: true,
|
2019-09-03 21:11:54 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-10-21 18:44:03 -04:00
|
|
|
if ( error.message && ( error.status < 500 || error.status >= 600 ) ) {
|
2019-09-03 21:11:54 -04:00
|
|
|
wpQueueError( error.message );
|
|
|
|
} else {
|
|
|
|
wpQueueError( pluploadL10n.http_error_image );
|
|
|
|
}
|
2014-03-23 19:45:19 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
return;
|
|
|
|
}
|
2014-03-23 19:45:19 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( ! times ) {
|
|
|
|
tryAgainCount[ file.id ] = 1;
|
|
|
|
} else {
|
|
|
|
tryAgainCount[ file.id ] = ++times;
|
2014-03-23 19:45:19 -04:00
|
|
|
}
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
// Try to create the missing image sizes.
|
|
|
|
$.ajax({
|
|
|
|
type: 'post',
|
|
|
|
url: ajaxurl,
|
|
|
|
dataType: 'json',
|
|
|
|
data: {
|
|
|
|
action: 'media-create-image-subsizes',
|
|
|
|
_wpnonce: wpUploaderInit.multipart_params._wpnonce,
|
2019-10-03 17:02:00 -04:00
|
|
|
attachment_id: id,
|
2019-11-03 12:09:02 -05:00
|
|
|
_legacy_support: 'true',
|
2019-09-03 21:11:54 -04:00
|
|
|
}
|
|
|
|
}).done( function( response ) {
|
|
|
|
var message;
|
2014-02-27 15:15:16 -05:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( response.success ) {
|
|
|
|
uploadSuccess( file, response.data.id );
|
|
|
|
} else {
|
|
|
|
if ( response.data && response.data.message ) {
|
|
|
|
message = response.data.message;
|
|
|
|
}
|
|
|
|
|
|
|
|
wpQueueError( message || pluploadL10n.http_error_image );
|
|
|
|
}
|
|
|
|
}).fail( function( jqXHR ) {
|
2019-10-21 18:44:03 -04:00
|
|
|
// If another HTTP 5xx error, try try again...
|
|
|
|
if ( jqXHR.status >= 500 && jqXHR.status < 600 ) {
|
2019-09-03 21:11:54 -04:00
|
|
|
tryAgain( up, error );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wpQueueError( pluploadL10n.http_error_image );
|
|
|
|
});
|
2019-11-03 12:09:02 -05:00
|
|
|
}
|
2019-09-03 21:11:54 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// Init and set the uploader.
|
2019-09-03 21:11:54 -04:00
|
|
|
uploader_init = function() {
|
|
|
|
uploader = new plupload.Uploader( wpUploaderInit );
|
|
|
|
|
|
|
|
$( '#image_resize' ).bind( 'change', function() {
|
|
|
|
var arg = $( this ).prop( 'checked' );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
setResize( arg );
|
|
|
|
|
|
|
|
if ( arg )
|
2019-09-03 21:11:54 -04:00
|
|
|
setUserSetting( 'upload_resize', '1' );
|
2012-08-22 20:04:18 -04:00
|
|
|
else
|
2019-09-03 21:11:54 -04:00
|
|
|
deleteUserSetting( 'upload_resize' );
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
uploader.bind( 'Init', function( up ) {
|
|
|
|
var uploaddiv = $( '#plupload-upload-ui' );
|
|
|
|
|
|
|
|
setResize( getUserSetting( 'upload_resize', false ) );
|
2014-02-27 15:15:16 -05:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( up.features.dragdrop && ! $( document.body ).hasClass( 'mobile' ) ) {
|
|
|
|
uploaddiv.addClass( 'drag-drop' );
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
$( '#drag-drop-area' ).on( 'dragover.wp-uploader', function() { // dragenter doesn't fire right :(
|
|
|
|
uploaddiv.addClass( 'drag-over' );
|
|
|
|
}).on( 'dragleave.wp-uploader, drop.wp-uploader', function() {
|
|
|
|
uploaddiv.removeClass( 'drag-over' );
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
} else {
|
2019-09-03 21:11:54 -04:00
|
|
|
uploaddiv.removeClass( 'drag-drop' );
|
|
|
|
$( '#drag-drop-area' ).off( '.wp-uploader' );
|
2012-08-22 20:04:18 -04:00
|
|
|
}
|
2012-10-25 16:53:38 -04:00
|
|
|
|
2014-03-23 19:45:19 -04:00
|
|
|
if ( up.runtime === 'html4' ) {
|
2019-09-03 21:11:54 -04:00
|
|
|
$( '.upload-flash-bypass' ).hide();
|
2014-03-23 19:45:19 -04:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
|
2016-06-16 00:54:29 -04:00
|
|
|
uploader.bind( 'postinit', function( up ) {
|
|
|
|
up.refresh();
|
|
|
|
});
|
|
|
|
|
2012-08-22 20:04:18 -04:00
|
|
|
uploader.init();
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
uploader.bind( 'FilesAdded', function( up, files ) {
|
|
|
|
$( '#media-upload-error' ).empty();
|
2012-08-22 20:04:18 -04:00
|
|
|
uploadStart();
|
|
|
|
|
2014-02-27 15:01:16 -05:00
|
|
|
plupload.each( files, function( file ) {
|
2020-07-03 19:15:03 -04:00
|
|
|
if ( file.type === 'image/heic' && up.settings.heic_upload_error ) {
|
|
|
|
// Show error but do not block uploading.
|
2021-06-24 15:12:00 -04:00
|
|
|
wpQueueError( pluploadL10n.unsupported_image );
|
|
|
|
} else if ( file.type === 'image/webp' && up.settings.webp_upload_error ) {
|
|
|
|
// Disallow uploading of WebP images if the server cannot edit them.
|
|
|
|
wpQueueError( pluploadL10n.noneditable_image );
|
|
|
|
up.removeFile( file );
|
|
|
|
return;
|
2020-07-03 19:15:03 -04:00
|
|
|
}
|
|
|
|
|
2014-02-27 15:01:16 -05:00
|
|
|
fileQueued( file );
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
up.refresh();
|
|
|
|
up.start();
|
|
|
|
});
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
uploader.bind( 'UploadFile', function( up, file ) {
|
|
|
|
fileUploading( up, file );
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
uploader.bind( 'UploadProgress', function( up, file ) {
|
|
|
|
uploadProgress( up, file );
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
uploader.bind( 'Error', function( up, error ) {
|
|
|
|
var isImage = error.file && error.file.type && error.file.type.indexOf( 'image/' ) === 0;
|
|
|
|
var status = error && error.status;
|
|
|
|
|
2019-10-21 18:44:03 -04:00
|
|
|
// If the file is an image and the error is HTTP 5xx try to create sub-sizes again.
|
|
|
|
if ( isImage && status >= 500 && status < 600 ) {
|
2019-09-03 21:11:54 -04:00
|
|
|
tryAgain( up, error );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uploadError( error.file, error.code, error.message, up );
|
2012-08-22 20:04:18 -04:00
|
|
|
up.refresh();
|
|
|
|
});
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
uploader.bind( 'FileUploaded', function( up, file, response ) {
|
|
|
|
uploadSuccess( file, response.response );
|
2012-08-22 20:04:18 -04:00
|
|
|
});
|
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
uploader.bind( 'UploadComplete', function() {
|
2012-08-22 20:04:18 -04:00
|
|
|
uploadComplete();
|
|
|
|
});
|
2013-11-15 00:56:09 -05:00
|
|
|
};
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2019-09-03 21:11:54 -04:00
|
|
|
if ( typeof( wpUploaderInit ) == 'object' ) {
|
2012-08-22 20:04:18 -04:00
|
|
|
uploader_init();
|
2013-11-15 00:56:09 -05:00
|
|
|
}
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
});
|