Michael
Michael

Reputation: 576

Laravel 5.6 displaying an svg icon in my blade view not working

I have an icon in this location stored: public/icons/list.svg and in my blade I try to display the icon like this:

{{ Html::image('icons/list.svg', 'list') }}

This results into this in my html page:

<img src="https://url.dev/icons/list.svg" alt="list">

But this unfortunately doesn't work it displays as if the file can not be found. (this works great for .png or .jpg files)

Am I doing something wrong here?

Upvotes: 2

Views: 4920

Answers (2)

Nikola Kirincic
Nikola Kirincic

Reputation: 3757

Sometimes Apache doesn't recognize media type for svg, so try adding in your .htaccess:

AddType image/svg+xml .svg .svgz

Upvotes: 2

Sethu
Sethu

Reputation: 1379

Sometimes it doesn't work for me either and I've used the source code of the svg image

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"  preserveAspectRatio="none">
    .
    .
    .
</svg>

to get the source code of svg, just open the svg in a browser and view the source

Upvotes: 1

Related Questions