Page MenuHomePhabricator

Extend IE PNG transparency hack to all PNG images
Closed, ResolvedPublic

Description

Author: achuggard

Description:
As we all know, IEs before 7 have issues with PNG alpha transparencies, however
I noticed that in IE 6 I was never having trouble with the site image in the
upper right (for the monobook skin), even though using the Logo extension that
would be a SVG image rasterized to PNG and should have the same issues.

I found that in skins/common/IEFixes.js there is a fixalpha() function that
fixes this issue for the logo image only. Would it be possible to modify that
function so that it would do the same thing for all images that are on a page
and not just the logo?


Version: 1.8.x
Severity: normal
OS: Windows XP
Platform: PC

Details

Reference
bz6765

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:19 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz6765.
bzimport added a subscriber: Unknown Object (MLST).

beheer wrote:

Inject the following into fixalpha() in IEFixes.js infront of the orginal if-statement:

var array_version = navigator.appVersion.split("MSIE")
var version = parseFloat(array_version[1])

if (((version < 7 && version >= 5.5 && document.body.filters) || isMSIE55) && !doneIEAlphaFix)
{
   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
      }
   }
    doneIEAlphaFix = true;
}

If you have to hack the code, it's probably not a WORKSFORME is it? :)

*** This bug has been marked as a duplicate of bug 2074 ***