#36294 closed enhancement (duplicate)
Allow retrieval of WordPress media types and their extensions
Reported by: | flixos90 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.5 |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
There have been a couple of occasions where I needed to access the list of media types and their file extensions that WordPress bundles. Unfortunately this list is only generated within the function wp_ext2type()
and cannot be accessed from the outside.
A use-case is when I wanted to create a file upload field in a form builder plugin, I would like the admin to be able to select the required file type, and for that I would like to use the list from that function. Then I could check for the extensions / their MIME types whenever an upload through that field would happen.
I would propose to introduce a separate function that returns this list of media types and their file extensions. This function could then be called in wp_ext2type()
.
Attachments (1)
Change History (5)
#1
@
9 years ago
- Keywords has-patch dev-feedback added
36294.diff introduces a new function wp_get_type_extensions()
that returns the list and calls that function from wp_ext2type()
.
I also included a new filter to adjust this list. At first I wondered whether we should move the original filter ext2type
into the new function, but I felt this would not be appropriate in terms of naming conventions. ext2type
would now only adjust the types for the wp_ext2type()
function while the filter wp_type_extensions
would be applied globally.
#2
@
9 years ago
- Keywords close added; dev-feedback removed
- Resolution set to duplicate
- Status changed from new to closed
Introduce
wp_get_type_extensions()
and a corresponding filter