2

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?

Michael
  • 556
  • 1
  • 8
  • 27

2 Answers2

2

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

AddType image/svg+xml .svg .svgz
Nikola Kirincic
  • 3,651
  • 1
  • 24
  • 28
1

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

Sethu
  • 1,299
  • 10
  • 13
  • You can also copy the svg straight out of illustrator, When you paste it into the codes it just pastes the complete svg code. – Yilmaz Apr 11 '19 at 12:02