Add Additional File Types to WordPress Media Library
- September 18, 2011
- Featured, Tips & Tricks
Although the Media library feature in WordPress spends most of its life uploading and storing images and graphics, it actually has quite a bit more functionality. It can serve as storage for various files, both multimedia and traditional. This allows WordPress site owners to provide downloads of documents, embed audio and video files and more.
For security reasons, the default installation of WordPress restricts the types of files you can uploaded to a list of commonly accepted, safe(r) formats. These include:
Images
- .jpg
- .jpeg
- .png
- .gif
Documents
- .pdf (Portable Document Format; Adobe Acrobat)
- .doc, .docx (Microsoft Word Document)
- .ppt, .pptx, .pps, .ppsx (Microsoft PowerPoint Presentation)
- .odt (OpenDocument Text Document)
- .xls, .xlsx (Microsoft Excel Document)
Audio
- .mp3
- .m4a
- .ogg
- .wav
Video
- .mp4, .m4v (MPEG-4)
- .mov (QuickTime)
- .wmv (Windows Media Video)
- .avi
- .mpg
- .ogv (Ogg)
- .3gp (3GPP)
- .3g2 (3GPP2)
- First, locate your functions.php file in your active theme folder. Generally, it will be found in the folder: /wp-content/themes/your-active-theme/functions.php.
- Open the functions.php in a text or code editor.
- Look up the mime type of the file support you want to add. This is very important, be sure to use the correct one.
- Add the code below to your functions.php
- Save changes and upload to your active theme folder, overwriting the original.
// Added to extend allowed files types in Media upload add_filter('upload_mimes', 'custom_upload_mimes'); function custom_upload_mimes ( $existing_mimes=array() ) { // Add *.EPS files to Media upload $existing_mimes['eps'] = 'application/postscript'; // Add *.AI files to Media upload $existing_mimes['ai'] = 'application/postscript'; return $existing_mimes; }
- If you add the code above to the end of your functions.php, be sure NOT to add any trailing blank lines (this is true of any modification of your functions.php file).
- Obviously, you will not get automatically generated thumbnail images of additional files types so you may wish to add intuitive names using the Alternative Text and Title fields in the Media upload form.
- Changes to the functions.php file only affect that single theme. If you change themes, you’ll have to modify your new functions.php file.
I'm the front-man of It's WordPress. I come from a diverse array of backgrounds, enjoying the opportunity to expand my knowledge base and skill set by re-inventing myself. I enjoy environments that focus on emerging information, technology and concepts. I put on the technical hat in my early 20s and never really looked back. I'm love technology and the internet, as well as the outdoors and avidly hike, kayak and camp every chance I get.
About Us
We can take you from concept, through design, development and deployment in one seamless process. Whether you choose a self-managed web site or need a continuing support relationship; we've got you covered.
CLICK TO EDIT
Request Consulation
Ready to transform your vision into a reality? Just looking to see what it takes to get the ball rolling. Tell us about your project and we can help. No spam. No obligation. Just answers.
-
- neon emmanuel
- July 11, 2014
Hmm, does adding this code updates, all file upload type on wordpress Blog, or it allows just some certain file
-
- Geoffrey Fortier
- November 25, 2015
Hi Neon, sorry for the delay in replying. You will have to add the mime type for each different file type you want to support, but you do not have to add the entire code block in its entirety each time. Does that make sense?
-
I changed the code and can upload .EPS file (logo), But the logo doesn’t show. It stays blank.. any ideas?
(The JPG logo shows normal)-
- Geoffrey Fortier
- November 26, 2013
Sorry I wasn’t more clear, Christian. Even though you can upload other file types, it doesn’t mean the web browser will render them (like EPS). You will still be limited by the browser’s technical abilities. This tip is usually used so that webmaster can provide downloadable files to their users.
-
-
- Alex Nartey
- September 18, 2013
Hi,
Admired is a great theme and am loving it.
I want to create a child theme but would like to know if its possible to
copy the whole folder of parent theme(Admired) and make some personal changes.Thanks for the good work.
-
- Pecinta Vektor
- August 13, 2013
Ternyata ada caranya !
Oh, there’s A Way to do it !Terima Kasih telah membaginya 🙂
Thanks for sharing 🙂 -
- ETS 2 Mods
- June 10, 2013
What if I want to remove files-types from default list? Let’s say I want all admins to be able to upload only .jpg files, is it possible?
-
- Geoffrey Fortier
- June 11, 2013
Hmn, never had call to do that myself with an Admin, but this article might set you on the right path to create that funcationality:
Good luck and let me know how it works out.
-
Pingback: Adding CBZ format to WordPress - eBabble
-
- Michel Guillaume
- April 12, 2013
Well explained, thank you.
Now, once you want to “Insert into post”, the corresponding file name comes with surrounding code. How can I customize this?-
- Geoffrey Fortier
- April 13, 2013
Hi Michel. After uploading the file to your Media library, but before you click “Insert into post”, you can change the “Title” field in the Attachment Details section. If you’ve already inserted the file/link into a post, you can click the Text tab (next to View) in the WordPress post/page editor and change the linked text between the hyperlink tags (a href). Hope that helps. Good luck!
-
- Grant
- March 6, 2013
Just wanted to say thanks for this snippet. Just what I needed to upload eps files.
This does work on WP 3.5.1.
-
- Webmaster, Abbey Theatre, St Albans
- July 16, 2012
A further apology – I mistyped our website address in my haste entering it in earlier posts. It should be
http://www.abbeytheatre.org.uk – I missed out an ‘a’
John McC
-
- Webmaster, Abbey Theatre, St Albans
- July 16, 2012
Well, I’ve tried this using WordPress 3.4.1, and it breaks the site completely and generates a Server Error 500 message.
I added the whole of the suggested code at the end of a copy of the functions.php in my Child Theme folder. I was careful to have no trailing spaces at the end.
This isn’t quite what the topic suggests, but seems to follow the guidelines for making changes via Child Themes, rather than replacing the original (twentyeleven) theme functions.php file.
Does this method not work with WP 3.x?
Tx if you can help find an alternative.
JohnMcC, Webmaster, Abbey Theatre St Albans
-
- Webmaster, Abbey Theatre, St Albans
- July 16, 2012
OOPS – I see the problem now.
I did the same for the functions.php file as for the other theme files, copied the whole of the file, then added the code at the end.
THAT’S WRONG for the functions.php file. You just include the code to want to ADD.
Now I’ve done that, changing the file and mime types to what I want to use, it works
Sorry for mistaken post
-
- Geoffrey Fortier
- July 16, 2012
Hi John. Glad you got the code snippet working. Nice troubleshooting! Best of luck with your web site.
-
Thanks very much – this worked so I could upload an .ai file when I needed to.
-
- Geoffrey Fortier
- March 26, 2012
You’re very welcome, Callie. Best of luck with your site!
-
Recent Posts
All Website Tags
Leave a Comment cancel
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Thanks very much – this worked so I could upload an .ai file when I needed to.
You’re very welcome, Callie. Best of luck with your site!
thanks
it works… awesome
Well, I’ve tried this using WordPress 3.4.1, and it breaks the site completely and generates a Server Error 500 message.
I added the whole of the suggested code at the end of a copy of the functions.php in my Child Theme folder. I was careful to have no trailing spaces at the end.
This isn’t quite what the topic suggests, but seems to follow the guidelines for making changes via Child Themes, rather than replacing the original (twentyeleven) theme functions.php file.
Does this method not work with WP 3.x?
Tx if you can help find an alternative.
JohnMcC, Webmaster, Abbey Theatre St Albans
OOPS – I see the problem now.
I did the same for the functions.php file as for the other theme files, copied the whole of the file, then added the code at the end.
THAT’S WRONG for the functions.php file. You just include the code to want to ADD.
Now I’ve done that, changing the file and mime types to what I want to use, it works
Sorry for mistaken post
Hi John. Glad you got the code snippet working. Nice troubleshooting! Best of luck with your web site.
A further apology – I mistyped our website address in my haste entering it in earlier posts. It should be
http://www.abbeytheatre.org.uk – I missed out an ‘a’
John McC
Just wanted to say thanks for this snippet. Just what I needed to upload eps files.
This does work on WP 3.5.1.
Well explained, thank you.
Now, once you want to “Insert into post”, the corresponding file name comes with surrounding code. How can I customize this?
Hi Michel. After uploading the file to your Media library, but before you click “Insert into post”, you can change the “Title” field in the Attachment Details section. If you’ve already inserted the file/link into a post, you can click the Text tab (next to View) in the WordPress post/page editor and change the linked text between the hyperlink tags (a href). Hope that helps. Good luck!
Pingback: Adding CBZ format to WordPress - eBabble
What if I want to remove files-types from default list? Let’s say I want all admins to be able to upload only .jpg files, is it possible?
Hmn, never had call to do that myself with an Admin, but this article might set you on the right path to create that funcationality:
http://wordpress.stackexchange.com/questions/8107/limit-image-upload-to-one-and-disable-audio-video-and-other-document-file-types
Good luck and let me know how it works out.
Ternyata ada caranya !
Oh, there’s A Way to do it !
Terima Kasih telah membaginya 🙂
Thanks for sharing 🙂
Hi,
Admired is a great theme and am loving it.
I want to create a child theme but would like to know if its possible to
copy the whole folder of parent theme(Admired) and make some personal changes.
Thanks for the good work.
I changed the code and can upload .EPS file (logo), But the logo doesn’t show. It stays blank.. any ideas?
(The JPG logo shows normal)
Sorry I wasn’t more clear, Christian. Even though you can upload other file types, it doesn’t mean the web browser will render them (like EPS). You will still be limited by the browser’s technical abilities. This tip is usually used so that webmaster can provide downloadable files to their users.
Hmm, does adding this code updates, all file upload type on wordpress Blog, or it allows just some certain file
Hi Neon, sorry for the delay in replying. You will have to add the mime type for each different file type you want to support, but you do not have to add the entire code block in its entirety each time. Does that make sense?