• Hi, I was using SVG image files in my theme before the upgrade to 4.0 and the images would preview in the backend just fine (like in the media manager), however, now they do not preview and I am met with a gray document icon when viewing them in version 4.0.

    I’m not using a plugin to add svg uploadability, just using some standard code in my functions.php

    function my_myme_types($mime_types){
    		$mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
    		$mime_types['mp4'] = 'video/mp4';
    		$mime_types['mp3'] = 'audio/mp3';
    		return $mime_types;
    	}
    	add_filter('upload_mimes', 'my_myme_types', 1, 1);

    Any ideas? is it a bug? Thank you for reading.

    Even though this is feedback…maybe this should be in the troubleshooting section.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    WordPress already knows about mp4 and mp3, so you don’t need those in there at all.

    It does not know about svg for the mime types, but that upload_mimes filter would only affect your ability to upload those files, not the ability of the backend to display them.

    Thread Starter cdyerkes

    (@cdyerkes)

    Thanks for the tip. I hadn’t tried those filetypes before.

    I see, so I guess the display issue would be a bug with WordPress 4.0. Bummer.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    No, it’s not a 4.0 bug. I can upload and see SVG’s in the media library just fine, with no additional code. I’m using Chrome, which can display SVGs normally though.

    SVGs work fine as far as I can see, so something else you have is interfering here.

    Thread Starter cdyerkes

    (@cdyerkes)

    I can upload them just fine.

    It’s the previews that aren’t working.

    I just did a test with a clean install of WordPress 4.0 and no previews. In 3.9.2 there were SVG previews.

    edit: also using latest stable chrome browser to upload.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Hmm. You’re right. I was mistaken, looking at the wrong site, I think.

    Near as I can figure, this was partially intentional. SVG’s are not supported for various reasons, and are unlikely to be supported by default because of security issues.

    Basically, it assumes that “image” types are safe, but in the case of SVG, that is not the case. SVG is not a safe format to allow for untrusted users. The fact that it “worked” before was simply an accident, it was never intended to work in that respect.

    Note that while the SVG is not displayed as the thumbnail or in the modal popup screen, the image is displayed if you click the “Edit more details” link in the bottom middle of the right column.

    To get it to display the image as a thumbnail or in the modal would take additional code to generate the proper metadata for it, and probably even more code to allow it to use it properly.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘SVG Previews no longer show in version 4.0’ is closed to new replies.