Using Transparent PNG's in IE5/6 without JavaScript

Submitting your vote...
Rating: 4.0 of 5. 11 vote(s).
Click the rating bar to rate this item.

Sometimes you need to make a site compatible with the old crappy Internet Explorer (IE5/6) when using transparent PNGs.

People often resort to various JavaScripts to convert the IMG tags into filters for Internet Explorer.

But the same can be done in TYPO3 directly by TypoScript!

Below is an example for this PNG Fix.

 

# This is the normal IMG tag shown in good browsers
lib.pngImage = COA
lib.pngImage {
  10 = IMAGE
  10.file = fileadmin/img/car.png
  10.file.import = uploads/tx_templavoila/
  10.file.import.field = field_image
  10.file.import.listNum = 0
  10.file.maxW = 600
}

# If the browser is Internet Explorer, and the version lower than 7,
# then we modify the lib.pngImage object
[browser = msie] && [version= <7]
lib.pngImage = COA
lib.pngImage {
   
      # first we create a dummy register value, in order to fill
      # the TSFE:lastImgResourceInfo array.
  20 = LOAD_REGISTER
      # The dummy object is just a copy of the original IMAGE object
  20.dummy.cObject < .10
      # But we change the type from IMAGE to IMG_RESOURCE
  20.dummy.cObject = IMG_RESOURCE
   
      # And unset the original 10 object
  10 >
   
      # Then we create a SPAN tag instead of the IMG tag.
      # The span tag uses the AlphaImageLoader filter
      # to display the transparent PNG correctly in Internet Explorer.
  30 = TEXT
  30.value = <span style="width:{TSFE:lastImgResourceInfo|0}px;height:{TSFE:lastImgResourceInfo|1}px;display:inline-block;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{TSFE:lastImgResourceInfo|3}', sizingMethod='scale');"></span>
  30.insertData = 1
}
[GLOBAL]
# Done! - Back to normal..

 


This snippet was submitted by Peter Klein




Comments


Houston, 20-12-08 01:27:
Really great fix!

BUT ... I installed RealURL and now the fix only works for the index page, all other pages, now show ... nothing - disable realUrl and it works again ... but I just can't see the connection ... HELP?!
Houston, 20-12-08 02:18:
ok ... excuse my n00bness - I should have thought a little harder and checked the code a little closer ... the relative link changed to an absolute link fixed my problem.

GREAT WORK, again Peter !

Add comment

* - required field

*



*
*

Top 10 Updates

Nice fonts using Google font API geändert am  20-May-2010 16:36:47
TS-based Searchbox for Indexed Search  geändert am  18-May-2010 18:27:15
TYPO3 SEO geändert am  30-Apr-2010 09:44:22
Search engine friendly graphical headers in TYPO3 geändert am  30-Apr-2010 09:33:44
Creating a simple Infocenter using TYPO3 geändert am  17-Nov-2009 12:12:52
Making the Section Menu work correctly with TemplaVoila geändert am  05-May-2009 12:27:17
Show pages with type "Not in Menu" in a sitemap geändert am  05-May-2009 12:11:17
Implementation of the DHTML menu from brainjar.com  geändert am  01-Feb-2009 14:02:48
Sample DHTML menu geändert am  01-Feb-2009 13:51:25
A introduction to the CONTENT object geändert am  26-Jan-2009 13:20:39

Latest comments

20-Aug-2010 16:31:13
pritam schrieb: Hello, Can any body tell me how to add the realurl in the typo3.
Articles
17-Aug-2010 15:25:30
Graham Solomon schrieb: I have developed a nice extension for using this Google Font API with TYPO3, along with their web...
Nice Fonts using Google font API
12-Aug-2010 17:39:44
Ritesh Jaiswal schrieb: I have added the above code into page template but it is not working. It only index the page into...
Index search
Deutsch
Search: