Amorette

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromAmorette
ToMe
SubjectContent negotiation for SVG
Date26 January 2008 09:02
Hello there,

I don't know if this is included in what you say you would help with, but
would you be able to give me some advice on serving SVG images to
SVG-capable browsers?

For the XHTML vs. HTML case, I choose the content served by looking for the
"application/xhtml+xml" accept string in the HTTP request header with PHP. I
was hoping to do something like that too for SVG vs. raster formats, but for
example in the headers sent by Firefox and Opera, there is no mention of
accepting SVG.

What would you suggest as the best way to select whether to serve SVG or a
raster format?

I suppose it's counter to your philosophy ;-) but I do want to take
advantage of the capabilities of SVG to the extent not allowed by raster
images, so I don't particularly want to just serve the raster image to
everyone (i.e. I just want the raster format to be served as a fallback so
that it doesn't blow up in browsers that cannot view SVG).

Thanks!

Amorette
FromMe
ToAmorette
SubjectRe: Content negotiation for SVG
Date27 January 2008 08:26
Amorette,

> What would you suggest as the best way to select whether to serve SVG or a
> raster format?

Personally, I would use object tags. The client works out if it should use
them or the fallback content, no negotiation or sniffing needed:

<object type="image/svg+xml" data="someimage.svg">
<img src="someimage.png" alt="etc">
</object>

This would work in Opera, Firefox, Safari, Konqueror, and any other browser
that supports SVG. It would also fall back nicely in other browsers,
including IE 7, and amazingly even IE 6 (anyone still using that outdated
browser deserves whatever they get, but in this case, it says the object tag
does not request a plug-in, so it ignores it and displays the fallback).

> I suppose it's counter to your philosophy ;-)

Graceful degradation is part of my philosophy.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromAmorette
ToMe
SubjectJust a word of thanks! (Not expecting a reply)
Date17 June 2008 23:03
Hi there!

I remember stumbling onto your web site (from which I learnt a lot!!) many
months ago and there were pages everywhere promoting the Opera browser. I'd
like to thank you for recommending it (yeah I know you work for them and
stuff :P) because that's what I'm using about 80% of the time now and it's
really nice (both to use and torture-test with...)! Though I still miss some
Firefox add-ons...

Oh and I should have thanked you for the reply to a question I asked a few
months ago (I think in January), but it seems I never got around to doing
so... so thank you for that too!

Amorette Yan
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.