So, I’ve mentioned Firefox and SVG Problems.
From the information I’ve read it should be fixed
in 4.0b7. I am running a nightly build of beta 8.
In this nightly build, you can use the img tag to
load an svg image, but it doesn’t auto resize if a
fixed size is written in the svg file. A problem I’ve
encountered before in my SVG tests.

So, what to do: Open the SVG file and look for
something that looks like

width=”500.00000px”
height=”500.00000px”

and replace it with

viewBox=”0 0 500 500″

Then firefox 4.0b8 will resize the image to the
size you’ve specified in the img tag.

Of course we don’t expect all firefox users to
run the latest beta, so, how will be to a fallback
to png?

I added a little javascript, which works for Firefox 4.0b6.
I will still have to test it for the latest regular build, but
I assume it will work too.

I am using this little JavaScript function

function SVGPNGImage(img){
    var src= img.src;
    src= src.replace(“.svg”, “.png”);
    img.onerror=undefined;
    img.src = src;
}

And the HTML will be like

In this example we assume  we have both

/images/sheep.svg
/images/sheep.png

on our server.

« »