Jump to content


Photo

user agents... .png or .gif?


  • Please log in to reply
5 replies to this topic

#1 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 10 October 2006 - 10:50 PM

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."?
http://www.DaveLinger.com
dave at linger dot com

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,025 posts

Posted 10 October 2006 - 11:02 PM

I'm only guessing here and haven't tried it, but can you use the return value from
<?php
$tran_color = imagecolortransparent ($image);  // note no color specfied
?>

to see if there is a transparent color for the image?

EDIT guess not, that wouldn't check browser, just the image.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 10 October 2006 - 11:57 PM

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

<img src="images/test
<?php
$agent = $_USER_AGENT; //or whatever that variable is
include('http://www.somesite.com/somepage.php?agent=$agent');
?>
" />

http://www.DaveLinger.com
dave at linger dot com

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,025 posts

Posted 11 October 2006 - 12:08 AM

The only thing  that comes to mind is

www.php.net/get_browser

Towards the end of that page there's a link get latest settings from

http://www.garykeith...s/downloads.asp

but whether there is the particular setting that you would need in there, I don't know
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 11 October 2006 - 12:31 AM

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?
http://www.DaveLinger.com
dave at linger dot com

#6 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 11 October 2006 - 02:33 AM

here's what I got to work; after downloading the appropriate .ini file and editing php.ini...

<?php
$ua = get_browser ();
if ( ( $ua->browser == "IE" ) && ( $ua->version < 7 ) ) {
echo ".gif";
}else{
echo ".png";
}
?>

Basically any browser EXCEPT IE 6 and below gets the .png :D
http://www.DaveLinger.com
dave at linger dot com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users