Duplicate Snippet
Embed Snippet on Your Site
Allow SVG Files Upload
Add support for SVG files to be uploaded in WordPress media.
Code Preview
php
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Could I simply add other file types to this snippet to allow other files not permitted by WordPress? For example, most of my clients need CAD/CAM file types used in engineering and manufacturing. File types such as .dxf and .dwg. Could I simply add…
$upload_mimes[‘dxf’] = ‘image/x-dxf’;
$upload_mimes[‘dwg’] = ‘image/x-dwg’;
Would love to know this too! Did you ever find out?
Hi Tim & Jacqueline,
Yes, you can use this filter to add support for multiple files but ideally you will use similar checks to ensure the mime type of the file is met same way we do for the svg in the 2nd part of the snippet.
Thanks for the info. I’d like to use this for uploading font files. Would you be able to show me how that would look? It’s a little over my head. 😉 Thank you!!
Hi Jacqueline,
You have to find the mime types for the font files and use that to extend the upload mimes the way we do it for SVG. For ttf/otf you can use something like this:
$upload_mimes[‘ttf’] = ‘font/ttf’;
$upload_mimes[‘otf’] = ‘font/otf’;
Feel free to reach out using the Contact page if you need more help.