question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

preserveAspectRatio

See original GitHub issue

Hi,

Thanks for your great plugin !

Small question, how i can keep the preserveAspectRatio=“none” attribute ?

I try with svgo :

removeAttrs: false,
removeUnknownsAndDefaults: false,

But i can’t keep this value.

Any idea ?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Hiswecommented, May 5, 2016

@am3000 a template could look like that

<svg xmlns="http://www.w3.org/2000/svg" style="width:0; height:0; visibility:hidden;"><% if(defs) {%>
  <defs>
      <%= defs %>
  </defs><% } %><% _.forEach( icons, function( icon ){ %>
    <symbol id="<%= icon.id %>" viewBox="<%= icon.svg.viewBox %>"<% if (icon.svg.originalAttributes.preserveAspectRatio) {%> preserveAspectRatio="<%= icon.svg.originalAttributes.preserveAspectRatio %>" <% }%>><% if (icon.title) {%>
      <title><%= icon.title %></title><% }%>
      <%= icon.svg.content %>
    </symbol><%
}); %></svg>

But I think I will port it to the default template

0reactions
Hiswecommented, Apr 27, 2016

@am3000 it should be possible to do this with a custom templates with a custom transformdata function.

the svg params contains the originalAttributes. You should be able to access preserveAspectRatio from here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

preserveAspectRatio - SVG: Scalable Vector Graphics | MDN
The preserveAspectRatio attribute indicates how an element with a viewBox providing a given aspect ratio must fit into a viewport with a ...
Read more >
Understanding SVG preserveAspectRatio - DigitalOcean
preserveAspectRatio gives us the ability to tell our graphic how to scale when the aspect ratio of the viewBox and viewPort are different....
Read more >
HTML svg preserveAspectRatio Attribute - Dofactory
The preserveAspectRatio attribute specifies if the SVG should be scaled uniformly. This attribute only works if the viewBox attribute is also present. Syntax....
Read more >
preserveAspectRatio - SVG: Scalable Vector Graphics
The preserveAspectRatio attribute indicates how an element with a viewBox providing a given aspect ratio must fit into a viewport with a different...
Read more >
SVG - preserveAspectRatio="none" not applying
preserveAspectRatio does nothing if your SVG doesn't have a viewBox . It is viewBox which tells the renderer how big the contents of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found