1

Using Sitecore 8.2 Update 7 -

When I upload SVGs to the media library, no size is being set. Sitecore flags this as an error (With the red line to the left). The images render fine on the site. So, does the fact that these SVGs have no size in Sitecore matter? And how to I set Sitecore to recognize the size when I upload the SVG?

3

SVG images don't have a "size" in terms of width value and height value in pixels unit, because they are vector graphics. So I don't think there is a way for Sitecore to recognize it.

When an SVG image is uploaded in Sitecore, the Width and Height fields are left blank:

enter image description here

The Size field is populated like for any other image type:

enter image description here

When an image in Sitecore doesn't have a value in the Width and Height fields, its <img> HTML element will be rendered without the width and height attributes. For example, if you include this image in a RTE field, the image element will be rendered as:

<img alt="" src="-/media/823B9A2DA31B4CF58AB3A037A3D5FC8D.ashx" />

instead of

<img alt="" src="-/media/823B9A2DA31B4CF58AB3A037A3D5FC8D.ashx?h=700&amp;w=700" style="height: 700px; width: 700px;" width="700" height="700" />

NOTE: The Sitecore image resizing using query strings parameters (like h and w) in the media asset url might not work for SVG images.

1
  • this is not exactly true. The svg file can contain a height and width attribute in the svg tag.
    – Nona Drake
    Apr 20 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.