SVG not displaying in Media Tab in Backend

I addes this code to allow SVG Uploads to the Media Library of wordpress:

function upload_svg ( $svg_mime ){
$svg_mime['svg'] = 'image/svg+xml';
return $svg_mime;
}

add_filter( 'upload_mimes', 'upload_svg' );
define('ALLOW_UNFILTERED_UPLOADS', true);

Than I added some SVGs to the Media Library. Using them works perfectly fine. The only Issue I have is that they will not be displayed in the Media Library. On other Pages in the Backend they display fine.

Is there anything I can do to display them in the Media Tab aswell? I couln’t find anything online on how to fix this issue.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

This is the solution to allow SVG upload and preview to Media area of WordPress: https://gist.github.com/benfrain/9422862

Method 2

Try to use this plugin: https://wordpress.org/plugins/wp-extra-file-types/.
I use it and .svg files seems fine in media lib.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x