Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#20990 closed enhancement (fixed)

Add filter information to get_allowed_mime_types() inline docs

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

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 14 years ago.

Download all attachments as: .zip

Change History (7)

#1 @JustinSainton
14 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
14 years ago

oh, didn't find that!
thank you.

#3 @JustinSainton
14 years ago

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

#4 @SergeyBiryukov
14 years ago

  • Component Upload → Inline Docs
  • Keywords has-patch commit added
  • Milestone Awaiting Review → 3.5

#5 @SergeyBiryukov
14 years ago

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

#6 @nacin
14 years ago

  • Owner set to nacin
  • Resolution → fixed
  • Status new → 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.