Support » Plugin: SVG Support » Sorry, this file type is not permitted for security reasons.

  • ResolvedPlugin Author Benbodhi

    (@benbodhi)


    In the recent releases of WordPress, there was changes made to the mime type handling to make sure that files have the extension they say they do (read more in this post).

    This poses an issue for SVG files without the <xml> tag in them.

    SVG is actually XML, and WordPress now requires us to have a line such as <?xml version="1.0" encoding="utf-8"?> in our SVG file when opened in a code editor. Some graphic software does remove this when saving/exporting our SVG.

    So, if you receive an upload error “Sorry, this file type is not permitted for security reasons.”, you simply need to open your SVG file in a code editor like sublime text and add the xml tag mentioned above to the first line and save. Then try uploading again.

    I will be looking into some way to avoid this issue if I can implement it into my plugin, but for the time being, this is the solution it seems.

    Thanks for your support and patience!

Viewing 12 replies - 16 through 27 (of 27 total)
  • That’s great @mainpart! I’ll try it in a while šŸ™‚

    Thanks!

    So whatsup, when will the fix be ready? šŸ™‚

    Plugin Author Benbodhi

    (@benbodhi)

    Long story, but been unable to spend the time Iā€™d like on the plugin for a while. Injuries, hospital, moving house (and country), other work… lots of things in my plate and Iā€™m the sole developer.

    Iā€™m going to try and dedicate some time in the coming week or so.

    I used this plugin on many websites. Now I’m mooving to a new plugin because I can’t upload the optimized images anymore. Other plugins don’t have this issue. Please fix it.

    I exported the SVG through Illustrator and optimised it using SVGOMG. Tried uploading it and it didn’t work. Opened up the SVG in Notepad++ and added the first line of code as suggested here. It worked. So yes, only adding that line should be enough as per my experience.

    • This reply was modified 7 months, 3 weeks ago by salmanravoof.

    As I see it the fix for this problem with the Avada theme (and possibly others) is to increase the priority number when you register the upload_mimes filter.

    Something like

    add_filter( 'upload_mimes', 'bodhi_svgs_upload_mimes', 11 );

    does the trick for me. This does break SVG-font upload support for the theme, but with WOFF support being near universal I don’t think that is much of an issue.

    Plugin Author Benbodhi

    (@benbodhi)

    Thanks for your feedback and tips @thomaslhotta and @salmanravoof

    sshattersley

    (@sshattersley)

    Hi @benbodhi I added the code mentioned to the SVG file but still cannot get it to upload into the media library. I am using the Avada theme. I saw @thomaslhotta ‘s post above, but am not sure where to add that code.

    @sshattersley

    In case you’re still struggeling: It needs to be added to your theme (preferably child theme)’s functions.php. @thomaslhotta’s code bit alone probably won’t do anything.

    You’ll need something like this (do correct me if I’m wrong):

    function bodhi_svgs_upload_mimes($mime_types) {
        $mime_types['svg'] = 'image/svg+xml';
        return $mime_types;
    }
    add_filter('upload_mimes', 'bodhi_svgs_upload_mimes', 11);

    See Plugin API/Filter Reference/upload mimes – WordPress Codex for more details about the upload_mimes filter.

    • This reply was modified 6 months, 3 weeks ago by mauri94.
    prodport

    (@prodport)

    I noticed that some services add a comment line at the top when you export the code. So, you need to make sure you add the line above that comment if there is one. Otherwise, you still fail.

    Plugin Author Benbodhi

    (@benbodhi)

    Thanks for the feedback @prodport, I appreciate that.

    Hoping to release an update to fix all this asap.

    Thanks for the great plugin @benbodhi – works sweet on other sites I’ve done that don’t use Avada.
    Thanks @mainpart for the Avada fix. Worked a treat. šŸ™‚

Viewing 12 replies - 16 through 27 (of 27 total)
  • You must be logged in to reply to this topic.