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
image/jpeg, application/pdf
List of WordPress MIME types
Use the following list to get the correct syntax for step 4, above.
File Extension | MIME Type |
---|---|
.jpg | image/jpeg, image/pjpeg |
.jpeg | image/jpeg, image/pjpeg |
.png | image/png |
.gif | image/gif |
.ico | image/x-icon |
application/pdf | |
.doc | application/msword |
.docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
.ppt | application/mspowerpoint, application/powerpoint, application/vnd.ms-powerpoint, application/x-mspowerpoint |
.pptx | application/vnd.openxmlformats-officedocument.presentationml.presentation |
.pps | application/mspowerpoint, application/vnd.ms-powerpoint |
.ppsx | application/vnd.openxmlformats-officedocument.presentationml.slideshow |
.odt | application/vnd.oasis.opendocument.text |
.xls | application/excel, application/vnd.ms-excel, application/x-excel, application/x-msexcel |
.xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
.psd | application/octet-stream |
.mp3 | audio/mpeg3, audio/x-mpeg-3, video/mpeg, video/x-mpeg |
.m4a | audio/m4a |
.ogg | audio/ogg, |
.wav | audio/wav, audio/x-wav |
.mp4 | video/mp4 |
.m4v | video/x-m4v |
.mov | video/quicktime |
.wmv | video/x-ms-asf, video/x-ms-wmv |
.avi | application/x-troff-msvideo, video/avi, video/msvideo, video/x-msvideo |
.mpg | audio/mpeg, video/mpeg |
.ogv | video/ogg |
.3gp | video/3gpp, audio/3gpp |
.3g2 | video/3gpp2, audio/3gpp2 |