WordPress.org

Make WordPress Core

Changeset 27316


Ignore:
Timestamp:
02/27/2014 08:00:55 PM (6 years ago)
Author:
azaozz
Message:

Upgrade Plupload to 2.1.1, props kovshenin, see #25663

Location:
trunk/src
Files:
3 added
7 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/media.php

    r27127 r27316  
    17611761
    17621762$plupload_init = array(
    1763     'runtimes' => 'html5,silverlight,flash,html4',
    1764     'browse_button' => 'plupload-browse-button',
    1765     'container' => 'plupload-upload-ui',
    1766     'drop_element' => 'drag-drop-area',
    1767     'file_data_name' => 'async-upload',
    1768     'multiple_queues' => true,
    1769     'max_file_size' => $max_upload_size . 'b',
    1770     'url' => $upload_action_url,
    1771     'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
    1772     'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
    1773     'filters' => array( array('title' => __( 'Allowed Files' ), 'extensions' => '*') ),
    1774     'multipart' => true,
    1775     'urlstream_upload' => true,
    1776     'multipart_params' => $post_params
     1763    'runtimes'            => 'html5,silverlight,flash,html4',
     1764    'browse_button'       => 'plupload-browse-button',
     1765    'container'           => 'plupload-upload-ui',
     1766    'drop_element'        => 'drag-drop-area',
     1767    'file_data_name'      => 'async-upload',
     1768    'url'                 => $upload_action_url,
     1769    'flash_swf_url'       => includes_url( 'js/plupload/Moxie.swf' ),
     1770    'silverlight_xap_url' => includes_url( 'js/plupload/Moxie.xap' ),
     1771    'filters' => array(
     1772        'max_file_size'   => $max_upload_size . 'b',
     1773    ),
     1774    'multipart_params'    => $post_params,
    17771775);
    17781776
     
    18611859<span class="max-upload-size"><?php printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($sizes[$u]) ); ?></span>
    18621860<?php
    1863 if ( ($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024 ) { ?>
    1864     <span class="big-file-warning"><?php _e('Your browser has some limitations uploading large files with the multi-file uploader. Please use the browser uploader for files over 100MB.'); ?></span>
    1865 <?php }
    18661861
    18671862    /**
  • trunk/src/wp-includes/js/plupload/handlers.js

    r27243 r27316  
    1 /* global plupload, pluploadL10n, ajaxurl, post_id, wpUploaderInit, deleteUserSetting, setUserSetting, getUserSetting */
    2 /* global resize_width, resize_height, shortform */
     1/* global plupload, pluploadL10n, ajaxurl, post_id, wpUploaderInit, deleteUserSetting, setUserSetting, getUserSetting, shortform */
    32var topWin = window.dialogArguments || opener || parent || top, uploader, uploader_init;
    43
     
    4342
    4443// check to see if a large file failed to upload
    45 function fileUploading(up, file) {
    46     var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10);
     44function fileUploading( up, file ) {
     45    var hundredmb = 100 * 1024 * 1024,
     46        max = parseInt( up.settings.max_file_size, 10 );
    4747
    4848    if ( max > hundredmb && file.size > hundredmb ) {
    49         setTimeout(function(){
    50 
     49        setTimeout( function() {
    5150            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>'));
     51                wpFileError( file, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) );
    5352                up.stop(); // stops the whole queue
    54                 up.removeFile(file);
     53                up.removeFile( file );
    5554                up.start(); // restart the queue
    5655            }
    57         }, 10000); // wait for 10 sec. for the file to start uploading
     56        }, 10000 ); // wait for 10 sec. for the file to start uploading
    5857    }
    5958}
     
    101100}
    102101
    103 function setResize(arg) {
     102function setResize( arg ) {
    104103    if ( arg ) {
    105         if ( uploader.features.jpgresize )
    106             uploader.settings.resize = { width: resize_width, height: resize_height, quality: 100 };
    107         else
     104        if ( window.resize_width && window.resize_height ) {
     105            uploader.settings.resize = {
     106                enabled: true,
     107                width: window.resize_width,
     108                height: window.resize_height,
     109                quality: 100
     110            };
     111        } else {
    108112            uploader.settings.multipart_params.image_resize = true;
     113        }
    109114    } else {
    110         delete(uploader.settings.resize);
    111         delete(uploader.settings.multipart_params.image_resize);
     115        delete( uploader.settings.multipart_params.image_resize );
    112116    }
    113117}
     
    300304            break;
    301305        case plupload.IO_ERROR:
    302             max = parseInt(uploader.settings.max_file_size, 10);
     306            max = parseInt( uploader.settings.filters.max_file_size, 10 );
    303307
    304308            if ( max > hundredmb && fileObj.size > hundredmb )
    305                 wpFileError(fileObj, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'));
     309                wpFileError( fileObj, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>') );
    306310            else
    307311                wpQueueError(pluploadL10n.io_error);
     
    398402    uploader_init = function() {
    399403        uploader = new plupload.Uploader(wpUploaderInit);
    400 
     404//console.dir(uploader)
    401405        $('#image_resize').bind('change', function() {
    402406            var arg = $(this).prop('checked');
     
    412416        uploader.bind('Init', function(up) {
    413417            var uploaddiv = $('#plupload-upload-ui');
    414 
     418window.console.dir('init...');window.console.dir(up);
    415419            setResize( getUserSetting('upload_resize', false) );
    416420
     
    433437        uploader.init();
    434438
    435         uploader.bind('FilesAdded', function(up, files) {
    436             var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10);
    437 
     439        uploader.bind('FilesAdded', function( up, files ) {
    438440            $('#media-upload-error').html('');
    439441            uploadStart();
    440442
    441             plupload.each(files, function(file){
    442                 if ( max > hundredmb && file.size > hundredmb && up.runtime != 'html5' )
    443                     uploadSizeError( up, file, true );
    444                 else
    445                     fileQueued(file);
     443            plupload.each( files, function( file ) {
     444                fileQueued( file );
    446445            });
    447446
     
    449448            up.start();
    450449        });
    451 
    452         // uploader.bind('BeforeUpload', function(up, file) {});
    453450
    454451        uploader.bind('UploadFile', function(up, file) {
  • trunk/src/wp-includes/js/plupload/wp-plupload.js

    r26213 r27316  
    33window.wp = window.wp || {};
    44
    5 (function( exports, $ ) {
     5( function( exports, $ ) {
    66    var Uploader;
    77
    8     if ( typeof _wpPluploadSettings === 'undefined' )
     8    if ( typeof _wpPluploadSettings === 'undefined' ) {
    99        return;
     10    }
    1011
    1112    /**
     
    3839        this.supported = this.supports.upload;
    3940
    40         if ( ! this.supported )
     41        if ( ! this.supported ) {
    4142            return;
     43        }
    4244
    4345        // Use deep extend to ensure that multipart_params and other objects are cloned.
     
    5355        // Proxy all methods so this always refers to the current instance.
    5456        for ( key in this ) {
    55             if ( $.isFunction( this[ key ] ) )
     57            if ( $.isFunction( this[ key ] ) ) {
    5658                this[ key ] = $.proxy( this[ key ], this );
     59            }
    5760        }
    5861
     
    6063        // Then set the proper plupload arguments to the ids.
    6164        for ( key in elements ) {
    62             if ( ! this[ key ] )
     65            if ( ! this[ key ] ) {
    6366                continue;
     67            }
    6468
    6569            this[ key ] = $( this[ key ] ).first();
     
    7074            }
    7175
    72             if ( ! this[ key ].prop('id') )
     76            if ( ! this[ key ].prop('id') ) {
    7377                this[ key ].prop( 'id', '__wp-uploader-id-' + Uploader.uuid++ );
     78            }
     79
    7480            this.plupload[ elements[ key ] ] = this[ key ].prop('id');
    7581        }
    7682
    7783        // If the uploader has neither a browse button nor a dropzone, bail.
    78         if ( ! ( this.browser && this.browser.length ) && ! ( this.dropzone && this.dropzone.length ) )
     84        if ( ! ( this.browser && this.browser.length ) && ! ( this.dropzone && this.dropzone.length ) ) {
    7985            return;
     86        }
    8087
    8188        this.uploader = new plupload.Uploader( this.plupload );
     
    8794
    8895        error = function( message, data, file ) {
    89             if ( file.attachment )
     96            if ( file.attachment ) {
    9097                file.attachment.destroy();
     98            }
    9199
    92100            Uploader.errors.unshift({
     
    99107        };
    100108
    101         this.uploader.init();
    102 
    103         this.supports.dragdrop = this.uploader.features.dragdrop && ! Uploader.browser.mobile;
    104 
    105         // Generate drag/drop helper classes.
    106         (function( dropzone, supported ) {
    107             var timer, active;
    108 
    109             if ( ! dropzone )
     109        this.uploader.bind( 'init', function( uploader ) {
     110            var timer, active, dragdrop,
     111                dropzone = self.dropzone;
     112
     113            dragdrop = self.supports.dragdrop = uploader.features.dragdrop && ! Uploader.browser.mobile;
     114
     115            // Generate drag/drop helper classes.
     116            if ( ! dropzone ) {
    110117                return;
    111 
    112             dropzone.toggleClass( 'supports-drag-drop', !! supported );
    113 
    114             if ( ! supported )
     118            }
     119
     120            dropzone.toggleClass( 'supports-drag-drop', !! dragdrop );
     121
     122            if ( ! dragdrop ) {
    115123                return dropzone.unbind('.wp-uploader');
     124            }
    116125
    117126            // 'dragenter' doesn't fire correctly,
    118127            // simulate it with a limited 'dragover'
    119             dropzone.bind( 'dragover.wp-uploader', function(){
    120                 if ( timer )
     128            dropzone.bind( 'dragover.wp-uploader', function() {
     129                if ( timer ) {
    121130                    clearTimeout( timer );
    122 
    123                 if ( active )
     131                }
     132
     133                if ( active ) {
    124134                    return;
     135                }
    125136
    126137                dropzone.trigger('dropzone:enter').addClass('drag-over');
     
    128139            });
    129140
    130             dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function(){
     141            dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function() {
    131142                // Using an instant timer prevents the drag-over class from
    132143                // being quickly removed and re-added when elements inside the
     
    139150                }, 0 );
    140151            });
    141         }( this.dropzone, this.supports.dragdrop ));
     152        });
     153
     154        this.uploader.init();
    142155
    143156        if ( this.browser ) {
     
    154167
    155168                // Ignore failed uploads.
    156                 if ( plupload.FAILED === file.status )
     169                if ( plupload.FAILED === file.status ) {
    157170                    return;
     171                }
    158172
    159173                // Generate attributes for a new `Attachment` model.
     
    235249                if ( pluploadError.code === plupload[ key ] ) {
    236250                    message = Uploader.errorMap[ key ];
    237                     if ( _.isFunction( message ) )
     251
     252                    if ( _.isFunction( message ) ) {
    238253                        message = message( pluploadError.file, pluploadError );
     254                    }
     255
    239256                    break;
    240257                }
     
    283300         */
    284301        param: function( key, value ) {
    285             if ( arguments.length === 1 && typeof key === 'string' )
     302            if ( arguments.length === 1 && typeof key === 'string' ) {
    286303                return this.uploader.settings.multipart_params[ key ];
     304            }
    287305
    288306            if ( arguments.length > 1 ) {
  • trunk/src/wp-includes/media-template.php

    r27313 r27316  
    100100                ?></p>
    101101
    102                 <?php if ( ( $GLOBALS['is_IE'] || $GLOBALS['is_opera']) && $max_upload_size > 100 * 1024 * 1024 ) :
    103                     $browser_uploader = admin_url( 'media-new.php?browser-uploader&post_id=' ) . '{{ data.postId }}';
    104                     ?>
    105                     <p class="big-file-warning"><?php printf( __( 'Your browser has some limitations uploading large files with the multi-file uploader. Please use the <a href="%1$s" target="%2$s">browser uploader</a> for files over 100MB.' ),
    106                         $browser_uploader, '_blank' ); ?></p>
    107                 <?php endif; ?>
    108 
    109102                <?php
    110103                /** This action is documented in wp-admin/includes/media.php */
  • trunk/src/wp-includes/media.php

    r27312 r27316  
    20542054
    20552055    $defaults = array(
    2056         'runtimes'            => 'html5,silverlight,flash,html4',
     2056        'runtimes'            => 'flash,html4', // html5,silverlight,
    20572057        'file_data_name'      => 'async-upload', // key passed to $_FILE.
    2058         'multiple_queues'     => true,
    2059         'max_file_size'       => $max_upload_size . 'b',
    20602058        'url'                 => admin_url( 'async-upload.php', 'relative' ),
    2061         'flash_swf_url'       => includes_url( 'js/plupload/plupload.flash.swf' ),
    2062         'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
    2063         'filters'             => array( array( 'title' => __( 'Allowed Files' ), 'extensions' => '*') ),
    2064         'multipart'           => true,
    2065         'urlstream_upload'    => true,
     2059        'flash_swf_url'       => includes_url( 'js/plupload/Moxie.swf' ),
     2060        'silverlight_xap_url' => includes_url( 'js/plupload/Moxie.xap' ),
     2061        'filters' => array(
     2062            'max_file_size'   => $max_upload_size . 'b',
     2063        ),
    20662064    );
    20672065
  • trunk/src/wp-includes/script-loader.php

    r27303 r27316  
    251251    );
    252252
    253     $scripts->add( 'plupload', '/wp-includes/js/plupload/plupload.js', array(), '1.5.7' );
    254     $scripts->add( 'plupload-html5', '/wp-includes/js/plupload/plupload.html5.js', array('plupload'), '1.5.7' );
    255     $scripts->add( 'plupload-flash', '/wp-includes/js/plupload/plupload.flash.js', array('plupload'), '1.5.7' );
    256     $scripts->add( 'plupload-silverlight', '/wp-includes/js/plupload/plupload.silverlight.js', array('plupload'), '1.5.7' );
    257     $scripts->add( 'plupload-html4', '/wp-includes/js/plupload/plupload.html4.js', array('plupload'), '1.5.7' );
    258 
    259     // cannot use the plupload.full.js, as it loads browserplus init JS from Yahoo
    260     $scripts->add( 'plupload-all', false, array('plupload', 'plupload-html5', 'plupload-flash', 'plupload-silverlight', 'plupload-html4'), '1.5.7' );
     253    // Back compat
     254    $scripts->add( 'plupload', '/wp-includes/js/plupload/plupload.full.min.js', array(), '2.1.1' );
     255    $scripts->add( 'plupload-all', '/wp-includes/js/plupload/plupload.full.min.js', array(), '2.1.1' );
    261256
    262257    $scripts->add( 'plupload-handlers', "/wp-includes/js/plupload/handlers$suffix.js", array('plupload-all', 'jquery') );
Note: See TracChangeset for help on using the changeset viewer.