Topic: [Plugin] PNG-Alpha Transparency for MSIE  (Read 34530 times)

Pages: [1] 2 3 4   Go Down

#1: 30-May-2005, 12:09 AM

Emeritus
xwisdom
Posts: 1,732

Hello Everyone,

Many thanks goes to Ryan for sharing this bit of code which I've managed to wrap inside a plugin so that it can be easily applied to your modx enabled website.

Trigger Event:
--------------------
OnWebPagePrerender

Plugin configuration:
----------------------
&spacer=PNG Spacer Path;string;assets/images &sm=Size Method;list;Scale,Crop,Image;Image

Create a new plugin with the above settings. Unzip the attached zip file and copy content of pngalpha4msie.txt into the plugin. Also copy the spacer.png image file into assets/images folder.

Here's an example of a png-24 alpha image tested in IE 6.0:

Note: You must be logged in before you can view images and download file attachments

Before (plugin disabled or not installed):


After (plugin enabled):



* pngalpha4msie.zip (11.86 KB - downloaded 1047 times.)

* pngie.png (102.94 KB, 335x250 - viewed 1337 times.)

* pngie2.png (101.9 KB, 295x233 - viewed 1309 times.)
« Last Edit: 30-May-2005, 09:23 AM by xwisdom »
xWisdom
www.xwisdomhtml.com
The fear of the Lord is the beginning of wisdom:
MODx Co-Founder - Create and do more with less.

#2: 30-May-2005, 01:40 AM

Administrator

zi
MODx Special Forces /
Posts: 3,555

May Peace Be On You

WWW
Thanks for great Plugin  Cheesy

it is really good since IE does not support PNG transparency images.

Best wishes and regards,

zi

#3: 1-Jun-2005, 11:27 AM

element
Posts: 5

WWW
I think this is a much needed plugin, thanks!  I'm courious though on what effect do the ie hack for the png alpha transparency have on the validation of the page as far xhtml and css compliance, I saw that hack a long time ago but can't remember exactly how it's done any more. 

Thanks for the great plugin!  Regardless there is a couple of sites that will make good use this  Grin
"Don't ask why or wither, just enjoy the icecream while it's on your plate." - Oscar Wild

"Stuff and nonsense for this valley to the next." - Zen Saying

#4: 1-Jun-2005, 12:36 PM

Testers

Lammikko
Posts: 435

WWW
Thank you very, very much!
QuickManager+ Support | Download

Mikko Lammi, Owner at Maagit

#5: 1-Jun-2005, 05:37 PM

Foundation

rthrash
Posts: 11,348

WWW
Quote
I think this is a much needed plugin, thanks!  I'm courious though on what effect do the ie hack for the png alpha transparency have on the validation of the page as far xhtml and css compliance, I saw that hack a long time ago but can't remember exactly how it's done any more. 

I don't think it negatively affects validation, FWIW. Also, any other ideas for a "compatibility kit" for Win IE less than the upcoming version 7.0. Hover:anything comes to mind for me...
MODx is a content managmeent framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Please help us help you when asking for assistance and read the wiki. Searching the forums from the top level helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.

#6: 1-Jun-2005, 10:42 PM

Emeritus
xwisdom
Posts: 1,732

? I'm courious though on what effect do the ie hack for the png alpha transparency have on the validation of the page as far xhtml and css compliance

Hi,

Thanks to all for the feedback. I don't see where this plugin should have any effect on xhtml and css. How it works is that it will only replace the "src" values for the necessary tags only when the IE browser is detected. So it should not change anything for FF, opera or any other browser.

Best regards,
xWisdom
www.xwisdomhtml.com
The fear of the Lord is the beginning of wisdom:
MODx Co-Founder - Create and do more with less.

#7: 14-Jul-2005, 05:05 AM

Testers

Dimmy
Posts: 2,001

Я не говорю по-русски 私は日本語を話さない

WWW
OK found a little bug with this cool plugin

the plugin needs image dimentions to work or els the spacer.png wil be 0 pixels and that way wil it not show the image.

I used the img TV to set a png but that resulted in the png file not showing and the source looked like this:

Code:
<img src='assets/images/spacer.png' style="width: 0; height: 0; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.elisabethschaap.nl/assets/images/header/header_img_nl.png', sizingMethod=);" /

then I changed the TV to a richeditor one and placed an png with that and it works fine. The source of the page rederd this way is:
Code:
<img src="assets/images/spacer.png" style="width: 610px; height: 124px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.elisabethschaap.nl/assets/images/header/header_img_nl.png', sizingMethod=);" alt=""/>

see the difference?

This: style="width: 0; height: 0; (image not showing)
or this: style="width: 610px; height: 124px (image showing)

Greets Dimmy
« Last Edit: 14-Jul-2005, 05:07 AM by Dimmy »

#8: 14-Jul-2005, 12:37 PM

Emeritus
xwisdom
Posts: 1,732

Hi Dimmy,

 I think the reason is because the Image TV does not set the width and height of the image. You can continue to use the RichText editor for the time being.

TP3 will include an Image Widget which will allow you to set the Width and height of the image.
xWisdom
www.xwisdomhtml.com
The fear of the Lord is the beginning of wisdom:
MODx Co-Founder - Create and do more with less.

#9: 14-Jul-2005, 07:11 PM

SpeedStreet
Posts: 155

Hi Dimmy,

 I think the reason is because the Image TV does not set the width and height of the image. You can continue to use the RichText editor for the time being.

TP3 will include an Image Widget which will allow you to set the Width and height of the image.

X,

I don't know if this will help, but I tried using a bunch of different hacks to make PNGs work for me, and the one that works the best is the one at: http://homepage.ntlworld.com/bobosola/

FWIW, please everyone keep in mind that IE7 will support PNG transparency. 

#10: 15-Jul-2005, 11:58 AM

Coding Team

Bravado
Posts: 1,108

"I can learn to resist anything but temptation..."

WWW
Well...I'll put my two cents in....

I think one thing everyone should realize is that the support for PNG alpha transparency is still not quite where it needs to be yet.  Granted, the support is there for many browsers and with some hacks it can be implemented.  But relying on it and designing a site around it might not be such a good thing yet.  I always do everything in terms of the "lowest common denominator". 

For example, when it comes to screen resolutions, 800x600 is about the lowest common denominator with 1024x768 quickly becoming the norms.  Now, this assumes that you're targetting the widest audience.  If you know that the majority is using higher screen resolutions then 1024x768 might be your target resolution.

Another example would be which revision of CSS to use.  Obviously, CSS 3 isn't really an option right now.  But you might want some CSS 2 stuff.  So developing your style sheets to degrade properly would definitely need to be addressed.

The point is that if you use PNG alpha transparencies, you'll need to think about how it'll degrade on browser that don't support transparencies or PNG's for that matter.  I certainly wouldn't like to visit a site and see a nasty grey box around an image.  I guess it just really depends on how you plan to use them and what your target audience will be. 

Just some food for thought.  Smiley

Jeff
Jeff Whitfield

"When someone asks you, A penny for your thoughts, and you put your two cents in, what happens to the other penny?"

-George Carlin

#11: 15-Jul-2005, 12:11 PM

Foundation

rthrash
Posts: 11,348

WWW
Agreed Jeff. I pretty much target IE 5.5+, Safari and Firefox now, with a smattering of Opera thrown in here and there. The other browsers just don't merit attention at this point for the amount of work required to support them (and the installed base compared tothe benefits it would bring to clients).

Regardless when they're deployed, they will all degrade acceptably so all the content will be accessible.
MODx is a content managmeent framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Please help us help you when asking for assistance and read the wiki. Searching the forums from the top level helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.

#12: 15-Jul-2005, 01:10 PM

SpeedStreet
Posts: 155

Agreed Jeff. I pretty much target IE 5.5+, Safari and Firefox now, with a smattering of Opera thrown in here and there. The other browsers just don't merit attention at this point for the amount of work required to support them (and the installed base compared tothe benefits it would bring to clients).

Regardless when they're deployed, they will all degrade acceptably so all the content will be accessible.

In my designs, I would concur with this philosophy.  5.5+

#13: 25-Feb-2006, 10:51 PM

gilbertn
Posts: 10

I love MODx!

Have you guys seen Dean Edwards' "IE7 Compatibility Script"?  It does a fantastic job of making IE6 behave like a vaguely standards-compliant browser  - I gather that even Microsoft themselves were using it in the early stages of building IE7 - squashing a lot of the worst layout bugs and adding support for transparent pngs too (as long as one names the files according to his convention: "foo.png" should be called "foo-trans.png" as I recall).

I include it by default in anything I do.

Check it out at http://dean.edwards.name/IE7/

Edit:
You can amend Dean's code so that it'll give alpha transparency to any png, however named.  I assume that he made it non-default behaviour to reduce the rendering overhead, but since I don't usually include that much heavy graphical content, I tend to do this just so as not to have to rename files.
« Last Edit: 26-Feb-2006, 07:25 AM by gilbertn »

#14: 26-Feb-2006, 02:58 AM

Testers

Dimmy
Posts: 2,001

Я не говорю по-русски 私は日本語を話さない

WWW
Have you guys seen Dean Edwards' "IE7 Compatibility Script"?  It does a fantastic job of making IE6 behave like a vaguely standards-compliant browser  - I gather that even Microsoft themselves were using it in the early stages of building IE7 - squashing a lot of the worst layout bugs and adding support for transparent pngs too (as long as one names the files according to his convention: "foo.png" should be called "foo-trans.png" as I recall).

I include it by default in anything I do.

Check it out at http://dean.edwards.name/IE7/

Nice

Would be great to have this as a plug-in

#15: 26-Feb-2006, 07:56 AM

gilbertn
Posts: 10

I love MODx!

Would be great to have this as a plug-in

Maybe as a default include?

I'd suggest so simply because
1) it obviates the need for the usual mountain of hacks for IE6
2) It can be included on demand with conditional commments, so no redundant load / rendering

The point is really about marketing the backwards / forwards compatibility of MODx: you guys have done such an amazing job of separating code from mark-up and style that porting css-driven layouts is a snap.  If an out-of-the-box implementation  takes care of the legacy nightmare, it's easier still, and therefore that much more appealing to new adopters.

This is a more pressing issue than ever before in the face of IE7.  MS are frantically trying to stop people from using css hacks, since switching the stylesheet to a specialised one that will resolve IE6 bugs will make the page render peculiarly in IE7, as they seem to have gone to some trouble to do a better job of complying to standards (not that it comes anywhere close to passing Acid Test 2!).

#16: 27-Feb-2006, 09:29 AM

Foundation

rthrash
Posts: 11,348

WWW
The best and safest strategy for IE6 and below hacks is to include them in Condititional Comments. That way it's much more certain to work in IE7 when it officially comes out.
MODx is a content managmeent framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Please help us help you when asking for assistance and read the wiki. Searching the forums from the top level helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.

#17: 27-Feb-2006, 10:20 AM

gilbertn
Posts: 10

I love MODx!

Agreed.

#18: 12-Mar-2006, 09:50 AM

trumpetmic
Posts: 46

Can someone help me use this plugin?

I installed it with the instructions in your post, but the pngs are still totally opaque in IE.  Is there something I need to do to activate it?

#19: 9-Apr-2006, 10:48 AM


joshlfisher
Posts: 249

WWW
I installed the plugin and it seems to function fine in IE, But....
It makes the graphics HUGE.
You can see it at fisherpublishinghouse.com  (use IE Wink )
What can I do to bring it down to size?
Visit Knight Technology Solutions at http://knightechnologysolutions.com

#20: 9-Apr-2006, 02:50 PM

Testers

Dimmy
Posts: 2,001

Я не говорю по-русски 私は日本語を話さない

WWW
you MUST set the height and width of the image for the plugin to work Ok

do not forget to set the plugin parameters and select the onwebpagePrerender selectionbox.
also refresh you website if you have cashing on.

I use this plugin all the time and it works great als make sure that you have the spacer.png in you assets/images folder

Greets Dimmy
Pages: [1] 2 3 4   Go Up
0 Members and 1 Guest are viewing this topic.