VF DSL 468x60

Using Transparent PNG's in IE5/6 without JavaScript

Submitting your vote...
Rating: 3.9 of 5. 10 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

Creating a simple Infocenter using TYPO3 geändert am  17-Nov-2009 11:12:52
Making the Section Menu work correctly with TemplaVoila geändert am  05-May-2009 10:27:17
Show pages with type "Not in Menu" in a sitemap geändert am  05-May-2009 10:11:17
Implementation of the DHTML menu from brainjar.com  geändert am  01-Feb-2009 13:02:48
Sample DHTML menu geändert am  01-Feb-2009 12:51:25
A introduction to the CONTENT object geändert am  26-Jan-2009 12:20:39
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

Latest comments

23-Feb-2010 04:40:25
Janna schrieb: what about the css? I am still not clear how to link typoscript with the css. Kindly...
Text menu
05-Feb-2010 18:38:50
Martin Terber schrieb: Didn't work for me neither. I will try in TMENU now.
Alternativ sorting for menu items
27-Jan-2010 23:41:31
romx schrieb: U know its dob't work apply to Tmenu))
Alternativ sorting for menu items
Deutsch
Search: