WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#26989 closed defect (bug) (fixed)

WP_Customize_Upload_Control cannot be extended to only accept .ico files

Reported by: ScottSmith Owned by:
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.4
Component: Upload Keywords:
Focuses: Cc:
PR Number:

Description

While adding a theme option for users of my theme to upload favicons (due to this request,) I realized that the WP_Customize_Image_Control class doesn't accept .ico image uploads. When the image upload dialogue was selected, .ico files would not be a selectable option, so I tried extending the WP_Customize_Image_Control class which was unsuccessful and then tried extending the WP_Customize_Upload_Control class in similar fashion to the WP_Customize_Image_Control class. Unfortunately, only png files are allowed and ice files are not. I've added both the mime type and file extension for the .ico file and neither allows the image to be selected.

This is what I ended up with:

class Decode_Customize_Favicon_Image_Control extends WP_Customize_Upload_Control {
public $extensions = array( 'ico', 'png', 'image/x-icon' );
}

This seems to be due to the fact that the JavaScript responsible for image uploads in wp-includes/js/plupload/plupload.js doesn't have .ico files in it's list of file types.

At this point, my abilities end. Thanks for hearing me out.

Change History (4)

#1 @nacin
6 years ago

  • Component changed from Options, Meta APIs to Upload
  • Focuses javascript administration template removed

#2 @celloexpressions
6 years ago

Semi-related: #16434 (favicons in core), #21483 (may change how WP_Customize_Image_Control works with relation to the media library).

#3 @celloexpressions
6 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Version changed from 3.8 to 3.4

#4 @celloexpressions
5 years ago

  • Milestone changed from Future Release to 4.1
  • Resolution set to fixed
  • Status changed from new to closed

With [30309], favicon uploads now work in the Customizer. Note that they will be treated as an unknown file type, which is fine, and that you can no longer force uploads to be .ico files in the UI, so you may need descriptive help text along with proper filetype checks in the sanitize callback.

Note: See TracTickets for help on using tickets.