WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#20990 closed enhancement (fixed)

Add filter information to get_allowed_mime_types() inline docs

Reported by: lspcity Owned by: nacin
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.4
Component: Inline Docs Keywords: has-patch commit
Focuses: Cc:

Description

In /wp-includes/functions.php there exists a function named get_allowed_mime_types().
In this function, all allowed mime types are hard-coded. There is no way to extend the list of mime types. So it's not possible to upload svg-files.

Please add SVG-files to this list:

'svg' => 'image/svg+xml',

Attachments (1)

20990.patch (515 bytes) - added by JustinSainton 5 years ago.

Download all attachments as: .zip

Change History (7)

#1 @JustinSainton
5 years ago

The list is filtered.

You can add the functionality with a very minimal plugin.

function js_add_mime_type( $mime_types ) {
	
	return array_merge( $mime_types, array( 'svg' => 'image/svg+xml' ) );

}

add_filter( 'upload_mimes', 'js_add_mime_type' );

#2 @lspcity
5 years ago

oh, didn't find that!
thank you.

@JustinSainton
5 years ago

#3 @JustinSainton
5 years ago

No worries - doc block should probably be updated to reflect the filter being used. Patch attached.

#4 @SergeyBiryukov
5 years ago

  • Component changed from Upload to Inline Docs
  • Keywords has-patch commit added
  • Milestone changed from Awaiting Review to 3.5

#5 @SergeyBiryukov
5 years ago

  • Summary changed from Support SVG in mime types to Add filter information to get_allowed_mime_types() inline docs

#6 @nacin
5 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [21180]:

Add note to get_allowed_mime_types() about the upload_mimes filter. props JustinSainton. fixes #20990.

Note: See TracTickets for help on using tickets.