Jump to content

php check for SVG support


legacyblade

Recommended Posts

Hello. I'm working on a site which I'd prefer to use SVG for some of the images. However, since not all browsers support SVG, I'm going to set a global variable to true if I detect the browser supports SVG. Using this, I can check to see if SVG is supported and show PNG/gif/jpg images in the place of the SVG in older browsers (and add a small banner at the top prompting them to upgrade to a modern browser). I can already do this using javascript. But seeing as javascript can be disabled, newer browsers that can support SVG might not be fed those images (which are much smaller files).

 

The javascript I'm using to test SVG support is as follows

 

document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Shape", "1.1")

the php code I tried, seeing as how it would make sense, is the following

DOMImplementation::hasFeature("http://www.w3.org/TR/SVG11/feature#Shape", "1.1")

(both of those were used in conditional branches)

 

Is there any way to get php to test for SVG support? Or do I need to stick with javascript?

 

Thanks for reading!

Link to comment
Share on other sites

hmm the only way i know in PHP Would be to get a list of all Browsers that Support .SVG Images And use the HTTP_USER_AGENT PHP Variable to check the browser

 

i only discovered SVG Images a few months ago while i was on Wikipedia looking at flags

 

Check this .. maybe it will help you with something

http://www.codingforums.com/archive/index.php/t-112277.html

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.