0

I have image inside svg with viewBox, is it possible to make image ignore scaling caused by viewBox and always keep size image 50x50?

<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" viewBox="0 0 200 200" preserveAspectRatio="xMidYMid meet">
    <image xlink:href="someimage.png" width="50" height="50"></image>
</svg>

Here is fiddle: http://jsfiddle.net/3LpxV/1/

Ruben Nagoga
  • 2,178
  • 1
  • 19
  • 30

2 Answers2

0

How about nested svg elements?

<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500">
    <image xlink:href="someimage.png" width="50" height="50"></image>
    <svg width="100%" height="100%" viewBox="0 0 200 200" preserveAspectRatio="xMidYMid meet">
        <!--other elements-->
    </svg>
</svg>
defghi1977
  • 5,081
  • 1
  • 30
  • 29
0

You can display image by css background-image property of svg element instead of using image element.
This image is not affected by viewBox of svg element.

    svg{
        background-image:url("***.jpg");
        background-repeat:no-repeat;
        background-size:50px 50px;
    }
defghi1977
  • 5,081
  • 1
  • 30
  • 29