Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Transparent PNG fix?
Anyone have a good solution for allowing transparent PNGs to render properly in IE for Vanilla?
0
This discussion has been closed.
Comments
EDIT: Actually there might be some ways here but I wouldn't use them to be honest. Too messy.
Whatever the case, I'd stay away from these kind of hacks, it's just not worth it imho. Cheers.
Save the code below to a file called pngfix.js and link to it in the HEAD section of each page...
// Correctly handle PNG transparency in Win IE 5.5 or higher. function correctPNG() { for(var i=0; i<document.images.length; i++) { var img = document.images[i] var imgName = img.src.toUpperCase() if (imgName.substring(imgName.length-3, imgName.length) == "PNG") { var imgID = (img.id) ? "id='" + img.id + "' " : "" var imgClass = (img.className) ? "class='" + img.className + "' " : "" var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " var imgStyle = "display:inline-block;" + img.style.cssText if (img.align == "left") imgStyle = "float:left;" + imgStyle if (img.align == "right") imgStyle = "float:right;" + imgStyle if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" img.outerHTML = strNewHTML i = i-1 } } } window.attachEvent("onload", correctPNG);
All my Windoze testers tell me it works.
It works with the demo, on their site and my local. But when I add it to an extension I have it doesn't work.
I added the following code to my CSS file like it said.
<style type="text/css"> img { behavior: url("pngbehavior.htc"); } </style>
Also, when viewing the demo on my local server it gives me an activex warning, asking me if i want to run it.
Yes, IE will show a warning, you have to deliver the .htc files with the proper MIME type through .htaccess, like so:
AddType text/x-component .htc
img { behavior: url("pngbehavior.htc"); }
If you add these line in the header with an extension, you have to put the path to pngbehavior.htc, url("http://domain.com/vanilla/extensions/PngExtension/pngbehavior.htc");
$Head->AddStyleSheet('http://domain/Vanilla/extensions/PNGFix/default.css');
Default.css:
img { behavior: url("http://domain/Vanilla/extensions/PNGFix/pngbehavior.htc"); }
And I placed the blank.gif in the folder as well. Just for shits-n-giggles I also tried just placing the entire pngbehavior.zip file contents in there, also doesn't work. I also tried pointing directly to the pngbehavior.zip css file, which doesn't work either. But if I view the demo in the zip, that does work. I don't get it.
I also tried another pngfix approach. I used the code at http://homepage.ntlworld.com/bobosola/, which works in other projects (non-Vanilla related), but does not work when I try to make it an extension. For that one all I did was place the JS in an extension folder and then added
$Head->AddString('<!--[if lt IE 7.]><script defer type="text/javascript" src="http://krak.servehttp.com/Vanilla/extensions/IEPNGFix/pngfix.js"></script><![endif]-->');
I tried the code Wanderer posted too with the previous format. No go. Any ideas?