Jump to content

user agents... .png or .gif?


DaveLinger

Recommended Posts

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
Share on other sites

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 is
include('http://www.somesite.com/somepage.php?agent=$agent');
?>
" />
[/code]
Link to comment
Share on other sites

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
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.