• 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 15 replies - 1 through 15 (of 31 total)
  • The error still persists with that header. You can try with this file (WP 5.0.2 and Avada theme): https://goo.gl/25CcPT

    Plugin Author Benbodhi

    (@benbodhi)

    Hi there,

    It looks like your file is optimised and may be missing some other information.
    Are you able to check it prior to optimising the file?

    It was the same. I had 2 almost identical files: I optimized one (the one I shared to you) and the raw file. Both of them had that header. Maybe you are right and there’s something else missing. The “raw” file was generated with Illustrator.

    • This reply was modified 5 years, 10 months ago by shamank.

    This is the raw file: https://goo.gl/jPhui2

    I tested it right now against this file and still the error: https://nimb.ws/Bc0iGt (the error is in spanish, my primary language).

    Plugin Author Benbodhi

    (@benbodhi)

    There’s something else going on here for you. I tried your raw file and it works fine.

    uploaded to library: https://www.dropbox.com/s/y78l9kr2szhgxjg/Screenshot%202019-01-07%2012.48.09.png?dl=0

    used in a post: https://www.dropbox.com/s/jszz0rvj1gc0tvz/Screenshot%202019-01-07%2012.50.25.png?dl=0

    Hi Benbodhi,

    same issue. I tried to upload the raw file provided by shamank and it doesn’t work with me. Not sure what can be done

    leiva logo-01.svg
    Sorry, this file type is not permitted for security reasons.

    Latest and freshly installed WP.

    Regards,
    Nat

    I tried a different plugin and it does work. So no rush ??

    Plugin Author Benbodhi

    (@benbodhi)

    That’s so strange that it’s working for me… however I’m using the latest nightly build which is in the 5.1 alphas.
    I’ll try and do some more extensive testing to reproduce the issue and try and troubleshoot it.

    Could it be something related to some theme hook? I’ve had issues in the past with svg support and theme manipulation of images. If you like, I can send to you the latest version of Avada theme (original, we buy our client’s themes in Themeforest) so maybe you can analyze or get a better idea of what’s comming on.

    Plugin Author Benbodhi

    (@benbodhi)

    It definitely could be, just deactivate that theme and test with the twentyseventeen theme to find out.

    It happened the same to me! Avada, spanish version. Drived me crazy! :S
    I finally deactivated Avada as you suggested and could upload svg files!
    Many thanks! So greatful! ??

    Plugin Author Benbodhi

    (@benbodhi)

    Unfortunately there’s not much I can do in terms of the theme. I’m not sure how they implement SVG but I’ve seen this sort of thing in the past, not just since WordPress 5.

    Glad you found the culprit though. Thank you for reporting back.

    Okay. I’ve debugged it with avada and got result.

    For a some reason upload of svg file returns with type font/svg, not image/svg
    This comes from avada filter mime_types that sets font/svg
    Therefore is does not pass hardcoded check of “image/” part in wp_check_filetype_and_ext function of media upload handler.

    So here comes the fix – paste it to eny executable part, maybe to your functions.php, and you are done.

    
    function fix_avada_mime_types($mime){
    	$mime['svg']='image/svg+xml';
    	return $mime;
    }
    add_filter('upload_mimes', 'fix_avada_mime_types', 99);
    
    Plugin Author Benbodhi

    (@benbodhi)

    Thanks for your update @mainpart.

    I have seen this issue with a number of themes that implement SVG fonts like this. Hopefully this helps future readers.

    I’ll look at why my plugin doesn’t take care of this… it may just be to do with the order of loading.

    Thanks again!

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘Sorry, this file type is not permitted for security reasons.’ is closed to new replies.