Thomas Hutton
Thomas Hutton

Reputation: 803

SVG Not Showing in Wordpress

Edit #1: Here's the code I put in functions.php:

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

Edit #2:

Here's my code to input it:

<img src="http://localhost/webdesign/wp-content/uploads/2017/02/Web-Design.svg" />

I've edited my functions.php file so I can upload SVG images (here's the article). So after I did that, I was able to link SVG files and I could see them. However, I went to take a nap, and when I came back, the SVG files never showed up. I could link them, but it was a white screen, and when I right-click to view image, it's just white, too.

Does anyone know what could be doing this? I've made a second localhost Wordpress website, and the same issue.

Upvotes: 3

Views: 22685

Answers (2)

Sheo Sagar
Sheo Sagar

Reputation: 917

Just you can do from the CSS class, only need to add SVG container width as below code:

.your-logo{width:300px;}

You can set your width as your require.

Upvotes: 2

Reza Saadati
Reza Saadati

Reputation: 1274

I had the same problem. The point is, you have to give that image a width and a height in order to make it visible.

Here is an example: Go to http://geigerag.ch/ ... there is a logo on the top in svg. As you may see, the logo has a width of 325px and a height of auto. Try to remove those values or try to right click on that image to view it in a new tab. However, the image will be blank.

Upvotes: 4

Related Questions