DaveLinger Posted October 10, 2006 Share Posted October 10, 2006 So basically I'm designing a new site, and the problem of transparent PNGs has arisen. Basically I just need some way to tell whether or not the browser that's looking at the page is capable of transparency in PNGs. In one of my past projects, I just made a LIST of compatible user agents, and made an IF statement, the problem with that being I have to update the list anytime the slightest update is released. Is there an easier way to make it work like "if you can, display this transparent PNG. Otherwise, show this gif."? Link to comment https://forums.phpfreaks.com/topic/23611-user-agents-png-or-gif/ Share on other sites More sharing options...
Barand Posted October 10, 2006 Share Posted October 10, 2006 I'm only guessing here and haven't tried it, but can you use the return value from[code]<?php$tran_color = imagecolortransparent ($image); // note no color specfied?>[/code]to see if there is a transparent color for the image? EDIT guess not, that wouldn't check browser, just the image. Link to comment https://forums.phpfreaks.com/topic/23611-user-agents-png-or-gif/#findComment-107207 Share on other sites More sharing options...
DaveLinger Posted October 10, 2006 Author Share Posted October 10, 2006 yeah... =/Is there no database that's constantly updated and I could just like include it in my page and it could return .gif if no or .png if yes? Then I could just make it like...[code]<img src="images/test<?php$agent = $_USER_AGENT; //or whatever that variable isinclude('http://www.somesite.com/somepage.php?agent=$agent');?>" />[/code] Link to comment https://forums.phpfreaks.com/topic/23611-user-agents-png-or-gif/#findComment-107225 Share on other sites More sharing options...
Barand Posted October 11, 2006 Share Posted October 11, 2006 The only thing that comes to mind iswww.php.net/get_browserTowards the end of that page there's a link get latest settings fromhttp://www.garykeith.com/browsers/downloads.aspbut whether there is the particular setting that you would need in there, I don't know Link to comment https://forums.phpfreaks.com/topic/23611-user-agents-png-or-gif/#findComment-107233 Share on other sites More sharing options...
DaveLinger Posted October 11, 2006 Author Share Posted October 11, 2006 so wait... using get browser... could I just make it say like... if it's any version of firefox, use PNG. Any version of IE EXCEPT 7 use GIF? Link to comment https://forums.phpfreaks.com/topic/23611-user-agents-png-or-gif/#findComment-107241 Share on other sites More sharing options...
DaveLinger Posted October 11, 2006 Author Share Posted October 11, 2006 here's what I got to work; after downloading the appropriate .ini file and editing php.ini...[code]<?php$ua = get_browser ();if ( ( $ua->browser == "IE" ) && ( $ua->version < 7 ) ) {echo ".gif";}else{echo ".png";}?>[/code]Basically any browser EXCEPT IE 6 and below gets the .png :D Link to comment https://forums.phpfreaks.com/topic/23611-user-agents-png-or-gif/#findComment-107258 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.