Using Transparent PNG's in IE5/6 without JavaScript

Submitting your vote...
Rating: 4.5 of 5. 6 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 00: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 01: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

Sample for dynamic image masks geändert am  16-Dec-2008 15:42:32
Useful Links geändert am  11-Dec-2008 10:06:17
Using Transparent PNG's in IE5/6 without JavaScript geändert am  04-Oct-2008 12:27:15
Using lightbox without extension geändert am  13-Jun-2008 14:20:51
Custom field for GMENU alt text geändert am  13-Jun-2008 13:58:07
Extending typoscript properties with stdWrap geändert am  13-Jun-2008 13:54:32
Create menus using data from other tables than "pages" V2  geändert am  24-Mar-2008 13:02:09
Login geändert am  17-Mar-2008 12:47:52
Forum geändert am  17-Mar-2008 10:07:47
Who is Typo3wizard.com geändert am  26-Dec-2007 16:07:32
Deutsch
Search: