WordPress.org

Make WordPress Core

Ticket #33713: big-fix.33713.diff

File big-fix.33713.diff, 2.0 KB (added by jagnew, 6 years ago)

Possible solution

  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index c0ac177..3331709 100644
     
    17341734                                ]
    17351735                        });
    17361736
     1737                        //If the library mime type is set to image, we should do the same for uploads
     1738                        if ( this.params.mime_type == 'image' ) {
     1739                                this.frame.uploader.options.uploader.filter = this.params.mime_type;
     1740                        }
     1741                       
    17371742                        // When a file is selected, run a callback.
    17381743                        this.frame.on( 'select', this.select );
    17391744                },
     
    23732378                                ]
    23742379                        });
    23752380
     2381                        //Since the library mime type is set to image, we should do the same for uploads
     2382                        this.frame.uploader.options.uploader.filter = 'image';
     2383               
     2384
    23762385                        this.frame.on('select', this.onSelect, this);
    23772386                        this.frame.on('cropped', this.onCropped, this);
    23782387                        this.frame.on('skippedcrop', this.onSkippedCrop, this);
  • src/wp-includes/js/plupload/wp-plupload.js

    diff --git src/wp-includes/js/plupload/wp-plupload.js src/wp-includes/js/plupload/wp-plupload.js
    index 09a37ce..e24d004 100644
    window.wp = window.wp || {}; 
    3232                                browser:   'browse_button',
    3333                                dropzone:  'drop_element'
    3434                        },
    35                         key, error;
     35                        filter, key, error;
    3636
    3737                this.supports = {
    3838                        upload: Uploader.browser.supported
    window.wp = window.wp || {}; 
    4949                this.plupload = $.extend( true, { multipart_params: {} }, Uploader.defaults );
    5050                this.container = document.body; // Set default container.
    5151
     52                //Restrict what file types can be uploaded. Taking a string of extensions 'jpg,gif,png'
     53                //If filter is set to 'image' we'll convert to correct extensions
     54                this.filter = options.filter;
     55                if ( this.filter == 'image' ) {
     56                        this.filter = 'jpeg,jpg,gif,png,svg,webp';
     57                }
     58
     59                if ( this.filter ) {
     60                        this.plupload.filters.mime_types = [ { extensions: this.filter } ];
     61                }
     62
    5263                // Extend the instance with options.
    5364                //
    5465                // Use deep extend to allow options.plupload to override individual