Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG images displayed as broken images on server

Tags:

html

svg

I'm encountering an odd problem showing .svg using simple img tags on Apache.

On my local computer, the images are visible. On my mt VPS, the images come across as broken links. When I right click on a broken image link and 'Open Image', it shows the images correctly (telling me that the path is correct).

My HTML looks like this:

<img width="32" height="32" alt="icon" id="create-wheel-icon2" src="public/assets/img/svg/idea_vect.svg" style="left: 230px; top: 57px; opacity: 1;">

Any thoughts?

like image 571
David Erwin Avatar asked Jun 05 '12 17:06

David Erwin


People also ask

Why is SVG not showing in HTML?

If you are trying to use SVG like <img src="image. svg"> or as a CSS background-image , and the file is linked to correctly and everything seems right, but the browser isn't displaying it, it might be because your server is serving it with an incorrect content-type.

Do SVG files lose quality?

One the major benefits of SVG is that they are resolution independent. This means that unlike file types such as JPG or PNG, SVGs retain the same quality no matter what screen resolution or size they are being at.

Why is SVG blurred?

If an SVG image has been imported into the document, and then scaled up, it appears perfectly fine on-screen, and when exported as a PDF. When it's printed, it appears blurred and pixelated. It looks like the bottom image has been rasterized at 30 x 30 pixels.

How do I fix SVG files?

By converting an SVG image or icon to an Office shape you can disassemble the SVG file and edit individual pieces of it. Converting the file is quite easy; just right-click the SVG image in your document, workbook, or presentation and select Convert to shape from the context menu that appears.


2 Answers

The info in link that Robert provided above worked for me:

.htaccess file with these rules:

AddType image/svg+xml svg svgz
AddEncoding gzip svgz
like image 187
Treb Avatar answered Sep 20 '22 14:09

Treb


Most likely you aren't serving the images with the correct mime type. There's some information on how to do that here: http://kaioa.com/node/45

You could always try to get a png file to work first to make sure it isn't something obvious about where you are putting the images.

like image 44
Robert Longson Avatar answered Sep 21 '22 14:09

Robert Longson