Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP SVG Check with fallback, possible?

Tags:

php

svg

fallback

is it possible to check (with PHP) if the browser supports SVG?

like ...

if( BROWSER support SVG )
{
   $iT = 'svg';              // Icon type
}
else
{
   $iT = 'png';              // Icon type
}    

in HTML code ...

<img src="icons/home.<?=$iT?>" class="icon" />



EDIT:
How about to check the browser and the version? Good idea?

$data['browser'] = strtolower($data['browser']);

if     ($data['browser'] == 'firefox' && (int)$data['browser']['version'] >= 10)
       $iT = 'svg';

elseif ($data['browser'] == 'safari'  && (int)$data['browser']['version'] >= 5)
       $iT = 'svg';

 .... and so on

PS: Did anybody know a nice SVG-Browser-Support-List?

like image 714
user970727 Avatar asked Oct 23 '22 04:10

user970727


1 Answers

You could probably do the check using JavaScript and Raphael, and then send that back to the server.

like image 163
halfer Avatar answered Nov 03 '22 03:11

halfer