Svg image file dosen't scale down

I have an Svg image file dosen’t scale down so i can’t use.
@Html.ImageFor(x => x.Logo, new Size(-1, 40))

I can use a png with no problem, then i get the correct size. But if i change the “Logo” to a svg file. It stays 150px high? Why is that?

Litium version: 6

I’ve checked for Litium 7, and for SVG it returns the image as is, without any resizing.

Since SVG images doesn’t have defined size, it doesn’t make sense to return a new, resized image. Instead, you could set the target size by styling.

Hmm, that makes sense. I guess I can tell the client to not upload a big svg to keep the file size down?

There seems to be some good optimization tools available online as well, like this one:

An SVG is actual en XML-file with cordinates how the image should be displayed. The file does not contains any size information so it can scale both up and down without losing in quality, but that is something that web-browser is doing.

Okey thanks, so the answer is simply to limit the size with css?


That’s the same as if you are using a canvas to render an image and you need to resize that one.

I will take a note and check if we can do something for the Html.ImageFor extension method so that can print out width/height information when rendering an svg image also.