How to display media files based on MIME type
The Posts Table Pro plugin lets you display any post type in a searchable table, including files directly from the media library. Media library files use a post type called 'attachment'.
Posts Table Pro supports MIME types so that you can easily create a table displaying media library files of a particular type, based on their MIME type or file extension. For example, this is useful if you want to list all the PDF files from the WordPress media library.
What is a MIME type in WordPress?
MIME is an acronym which stands for Multipurpose Internet Mail Extensions.
MIME types can be used to identify what type of content a media file is. For example, a web browser can recognise that a file has an extension of .jpg and understand that it is therefore an image file.
WordPress supports MIME types, and uses them to perform tasks such as allowing you to upload some types of file to the media library but not others.
How to list files based on their MIME type
The following instructions explain how to use Posts Table Pro to list media files with a specific MIME type:
- Go to Post Tables → Add New.
- Give your table a name and choose 'Media' from the list of post types. This tells the table to display the attachment post type, i.e. media library files.
- On the next page ("Refine"), click on 'Select specific media' and then 'MIME type'.
- Now enter a comma separated list of the MIME type(s) that you want to display in the table, for example: such as
List of WordPress MIME types
Use the following list to get the correct syntax for step 4, above.
|File Extension||MIME Type|
|.ppt||application/mspowerpoint, application/powerpoint, application/vnd.ms-powerpoint, application/x-mspowerpoint|
|.xls||application/excel, application/vnd.ms-excel, application/x-excel, application/x-msexcel|
|.mp3||audio/mpeg3, audio/x-mpeg-3, video/mpeg, video/x-mpeg|
|.avi||application/x-troff-msvideo, video/avi, video/msvideo, video/x-msvideo|