Cannot get .svg files to work

Posted by Community Admin on 04-Aug-2018 17:41

Cannot get .svg files to work

All Replies

Posted by Community Admin on 20-Nov-2012 00:00

I am trying to use .svg image files in my sitefinity site but they are not working.  The content-type that is being returned in the header when the svg is requested is 'text/html'.  I have had our server team add the correct mime type of 'image/svg+xml' and I have also created a mime mapping for it under Settings > Libraries > Mime Mappings with the same correct information.  Even after an IIS reset it is still returning 'text/html' in the header.  Is there something I'm missing or something else I can check?

Posted by Community Admin on 23-Nov-2012 00:00

Hello Matt,

Can you please let us know how exactly you reproduce the problem. I am able to upload .svg files in Sitefinity documents and then download them. A video, illustrating the problem would be helpful.  

Greetings,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 26-Nov-2012 00:00

Hi Jen,
I've attached two videos.  In the first one, I try uploading a svg on a page and it displays the error message I am getting in Chrome.  In the second  video, I have uploaded a svg file on the back end into my theme, I then use css to try to display the image as a background. Using Chrome's developer tools, I have displayed the mime type message I'm getting.  The other thing to note is that if I go directly to the image, it shows up fine.  This is illustrated at the end of my video.  I hope this helps!

(videos look best using 'large player') I have also attached the error messages, they are difficult to read in the video.
Video1: www.youtube.com/watch
Video2: www.youtube.com/watch

Thanks,
Matt

Posted by Community Admin on 29-Nov-2012 00:00

Hello Matt,

I was able to reproduce the uploading of .svg files problem. the exception is actually raised in the UploadImage method by a System method, called FromStream.

img = System.Drawing.Image.FromStream(source);

I researched the problem and found out in a few forum threads that the class, which contains the method, actually doesn't support such files - svg.

Please excuse us for the inconvenience, but this this turns out to be a problem out of our scope, which is related to System classes and we cannot change the implementation of the method.

Regards,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 29-Nov-2012 00:00

Thanks for the Reply Jen,
So this means that you cannot upload SVG's in Sitefinity?  You said that you were able to upload SVG's in your previous post above. How did you get it to work that time? If you were not able to get it to work, do I need to submit a bug?  How about the second video I posted above.  If I reference an SVG that is hosted on someone else's site it works fine but if I reference it hosted on my sitefinity website the svg will not show up because it has the wrong mime type.  Is this also a problem with the class?

Posted by Community Admin on 26-Mar-2013 00:00

Hey Jen, is there any way to get an SVG to work?  

Posted by Community Admin on 28-Mar-2013 00:00

Hi Matt,

I believe what Jen was trying to say is that uploading *.svg files is possible trhough the Documents and Files section (i.e. it will be treated as a file), however our Images implementation does not support *.svg.

You can still store the *.svg-s under Documents and files and then retrieve them in your widgets using our Documents API

All the best,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 06-Aug-2013 00:00

css-tricks.com/.../

 

Using data URI's works. Not my favorite technique cause they are lengthy and client has to download it every time. Still, if it's just an svg here and there it will work.

If you want to support both svg and png for a given image, go ahead and put both in your document at the same spot. Then give png images the css class "imagePNG" and your svg images the "imageSVG" class. Rules in CSS are as follows:

.svg .imagePNG,
.no-svg .imageSVG display: none;

This should serve the right image to the client and allow you to utilize SVG when your client browser actually can.

Hope this helped!

Posted by Community Admin on 07-Dec-2013 00:00

so is there really no way to use an SVG as a background image in CSS? We don't want to have to use Data-uris. 

We're not even trying to upload svgs, we just have some that are part of our theme.

Matt did you every get this working?

This thread is closed