Customizer: Restrict image control uploaders to only allow image file types. see #22149.
git-svn-id: http://core.svn.wordpress.org/trunk@22492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2ae40e6af5
commit
44314b715c
|
@ -145,9 +145,17 @@
|
|||
browser: this.container.find('.upload'),
|
||||
dropzone: this.container.find('.upload-dropzone'),
|
||||
success: this.success,
|
||||
plupload: {},
|
||||
params: {}
|
||||
}, this.uploader || {} );
|
||||
|
||||
if ( control.params.extensions ) {
|
||||
control.uploader.plupload.filters = [{
|
||||
title: api.l10n.allowedFiles,
|
||||
extensions: control.params.extensions
|
||||
}];
|
||||
}
|
||||
|
||||
if ( control.params.context )
|
||||
control.uploader.params['post_data[context]'] = this.params.context;
|
||||
|
||||
|
|
|
@ -402,6 +402,7 @@ class WP_Customize_Upload_Control extends WP_Customize_Control {
|
|||
public $type = 'upload';
|
||||
public $removed = '';
|
||||
public $context;
|
||||
public $extensions;
|
||||
|
||||
/**
|
||||
* Enqueue control related scripts/styles.
|
||||
|
@ -425,6 +426,9 @@ class WP_Customize_Upload_Control extends WP_Customize_Control {
|
|||
|
||||
if ( $this->context )
|
||||
$this->json['context'] = $this->context;
|
||||
|
||||
if ( $this->extensions )
|
||||
$this->json['extensions'] = $this->extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -456,6 +460,7 @@ class WP_Customize_Image_Control extends WP_Customize_Upload_Control {
|
|||
public $type = 'image';
|
||||
public $get_url;
|
||||
public $statuses;
|
||||
public $extensions = 'jpg,jpeg,gif,png';
|
||||
|
||||
protected $tabs = array();
|
||||
|
||||
|
|
|
@ -313,6 +313,9 @@ function wp_default_scripts( &$scripts ) {
|
|||
'cancel' => __( 'Cancel' ),
|
||||
'close' => __( 'Close' ),
|
||||
'cheatin' => __( 'Cheatin’ uh?' ),
|
||||
|
||||
// Used for overriding the file types allowed in plupload.
|
||||
'allowedFiles' => __( 'Allowed Files' ),
|
||||
) );
|
||||
|
||||
$scripts->add( 'media-models', "/wp-includes/js/media-models$suffix.js", array( 'backbone', 'jquery' ), false, 1 );
|
||||
|
|
Loading…
Reference in New Issue