Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#33415 closed enhancement (duplicate)

WP_Customize_Media_Control mime_type parameter

Reported by: istanbulmmv's profile IstanbulMMV Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1
Component: Customize Keywords: dev-feedback
Focuses: administration Cc:

Description

The WP_Customize_Media_Control mime_type parameter filters media modal output correctly but still enables the user to upload a file type that does not meet the mine_type stipulation.

Example code:

function site_logo_customizer_control( $wp_customize ) {
        $wp_customize->add_setting( 'custom_site_logo', array(       
                'sanitize_callback'     => 'absint',
                'type'                  => 'option',
        ) );

        $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'custom_site_logo', array(
		'section'       => 'title_tagline',
		'settings'      => 'custom_site_logo',
                'label'         => __( 'Site Logo' ),
                'mime_type'     => array('image/jpeg','image/gif','image/png'),
                'priority'      => 30,
	) ) );
}
add_action( 'customize_register', 'site_logo_customizer_control' );

Change History (4)

#1 @DrewAPicture
9 years ago

  • Keywords dev-feedback added

#2 @westonruter
9 years ago

  • Version changed from 4.3 to 4.1

This was introduced in #21483, in changeset [30309].

@celloexpressions Can you advise?

#3 @celloexpressions
9 years ago

This is a limitation of the media modal - the library can be filtered to only show a particular type of content, but anything can be uploaded. I'm not sure if there's an easy way to change that specifically for customizer controls, but this may need to be a media ticket instead, that could then implement any changes back in the Customizer.

In terms of UX, it would probably be good if inappropriate file types are rejected on upload here.

#4 @celloexpressions
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This is a duplicate of #33713, which has a patch.

Note: See TracTickets for help on using tickets.