PNG Fix
November 26th, 2007A quick, lightweight fix for IE PNG transparency support
The PNG Fix jQuery plug-in was developed to create a quick-and-easy fix for the PNG transparency issue in Internet Explorer 6. As it utilizes the jQuery framework, support is restricted to IE 6. At some point I will develop a stand-alone version, but for speed and efficiency a jQuery plug-in solution is hard to beat. With thanks to Angus Turnbull for Twin Helix’s original fix.
Update:
- 1.1 - Updated example HTML and removed deprecated repeat value for the repeatMethod option
- 1.2 - Fixed regex match error and revised sizing methods
Please note, repeatable backgrounds aren’t supported by the AlphaImageFilter (which this plug-in uses to render the graphics). You must either choose to crop the image into the size of the DOM element (default option) or scale/stretch the image to the size of the applied element.
Background positions are also redundant when using the fix as AlphaImageFilter only renders from the top left corner of the element.
Download Javascript source file (jquery.pngfix.js 8kb) or example pack (.zip)
Examples
To apply the fix to all images within the page:
jQuery(function($) {
$("img").pngfix();
});
A more efficient approach would be to apply it to all image elements that reference PNGs, or directly via IDs.
jQuery(function($) {
$("img[@src$=png], #image-one, #image-two").pngfix();
});
Options
There are currently two options for this plug-in:
- repeatMethod
- Choose between the three options for background scaling (inline with the MSDN guidance for the AlphaLoader filter.
- Crop: renders the image at initial size.
- Scale: stretches the image to the size of applied element.
Download Javascript source file (jquery.pngfix.js 8kb) or example pack (.zip)
Hello there! I stumbled upon your site looking for a solution to the google maps and IE6 PNG problem. I’m using a joomla template from Rocket Themes that uses a great deal of transparent images, so I need to keep transparency, but I’d also like to use Google maps.
I know basically nothing about Javascript….I do know that I’m using mootools in several places and that that can be a conflict. Found a page here that gives some information about getting around it (basically using something other than $ as a shortcut:
http://docs.jquery.com/Using_jQuery_with_Other_Libraries
Any help on implementing this would be greatly appreciated.
Thanks.
From Stephen Moseley December 31st, 2007 at 3:57 pm