MSIE 6, PNG, and Web Server 7

MSIE 6 handles PNG Alpha Channels really badly. For years now I've not used them because of MSIE 6's poor implementation, and this means modern browsers that can handle them have not been working at their best while I designed with badness in mind.

"Stupid MSIE 6," I'd grumble as I made yet another low bit-depth image, edges aliased to an "average" background color, a single background color. "I was making GIF images like this in 1996. When does The Future start?"

So now I've decided to just present craptacular images to MSIE 6 and let all the rest of the browsers in the world (including MSIE 7) get that Alpha Channel Loving they crave. Here's how I did it without have to modify a single HTML file or PHP application.

Web Server 7.0's spiffy IF/Then/Else syntax lets me do conditional request processing based on a large number of variables (and would let me define my own for later evaluation if needed). I've taken advantage of this feature to selectively send crappy graphics to MSIE 6 and send nice 8-bit+Alpha PNG images to everyone else with this stanza (placed below the final NameTrans):

<If $browser =~ 'MSIE 6' and
        $uri =~ '\^.\*\\.png$' and
        $uri !~ '_low\\.png$' and
        not $restarted and
        $path =~ '(.\*)\\.png' >
    PathCheck fn="set-variable" $new_path="$1_low.png"
  <If -e $new_path and
        $uri =~ '(.\*)\\.png' >
    PathCheck fn="restart" uri="$1_low.png"
  </If>
</If>

This evaluates a request by evaluating four conditions:

  1. Is the browser MSIE 6?
  2. And is the file being requested a PNG file?
  3. And the PNG file is not a file named SOMETHING_low.png?
  4. And the request has not already been restarted intnerally
  5. And a low-quality copy of the requested file does exist?

If all of these conditions evaluate to true then the enclosed PathCheck is executed. The PathCheck silently serves a low quality form of the graphic (name SOMETHING_low.png) rather than the Alpha Channel Goodness that everyone else gets (called SOMETHING.png). In my HTML/PHP/JSP/Whatever I just use an image tag pointing to SOMETHING.png and let Web Server worry about whether MSIE 6 is getting the Alpha Channel Goodness or low quality version of the file.

The more I use it the more I'm loving Web Server 7. Yay!

Comments:

I think it'd probably be simpler to use a single <If>:

<If not $restarted and
$browser =~ 'MSIE 6' and
$uri =~ '(.\*)\\.png$' and
$uri !~ '_low\\.png$' and
$path =~ '(.\*)\\.png$' and
-f "$2_low.png">
PathCheck fn="restart" uri="$1_low.png"
</If>

(...formatted properly, of course)

Posted by Chris Elving on October 11, 2007 at 09:22 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

jmccabe

Search

Categories
Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today