Improvements of Image format dropzone

* Limit drag-drop Image format zone to HTML5 runtime
* Only keep the first file dropped
* Only upload image files
* Fix CSS for the progress bar

props azaozz. see #24291.

git-svn-id: http://core.svn.wordpress.org/trunk@24236 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Mark Jaquith
2013-05-10 18:49:05 +00:00
parent 4b174612ab
commit 917fbaa81c
2 changed files with 17 additions and 7 deletions

View File

@@ -59,16 +59,27 @@ window.wp = window.wp || {};
'</div>'].join( '' ) );
}
function imageFormatUploadFilesAdded( uploader, files ) {
$.each( files, function( i, file ) {
if ( i > 0 )
uploader.removeFile(file);
});
}
var uploader = {
dropzone: $('.wp-format-media-holder[data-format=image]'),
success: imageFormatUploadSuccess,
error: imageFormatUploadError,
plupload: {},
error: imageFormatUploadError,
plupload: {
runtimes: 'html5',
filters: [ {title: 'Image', extensions: 'jpg,jpeg,gif,png'} ]
},
params: {}
};
uploader = new wp.Uploader( uploader );
uploader.uploader.bind( 'BeforeUpload', imageFormatUploadStart );
uploader.uploader.bind( 'UploadProgress', imageFormatUploadProgress );
uploader.uploader.bind( 'FilesAdded', imageFormatUploadFilesAdded );
function switchFormatClass( format ) {
formatField.val( format );