# PNG Fix not working with Unique Identifiers on image paths

**URL:** <https://www.ruby-forum.com/t/png-fix-not-working-with-unique-identifiers-on-image-paths/110393>\
**Category:** Rails\
**Created:** [July 26, 2007, 12:00am UTC](https://www.ruby-forum.com/t/png-fix-not-working-with-unique-identifiers-on-image-paths/110393 "2007-07-26T00:00:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkanders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dkanders](https://www.ruby-forum.com/u/dkanders)\
**Post date:** [July 26, 2007, 12:00am UTC](https://www.ruby-forum.com/t/png-fix-not-working-with-unique-identifiers-on-image-paths/110393/1 "2007-07-26T00:00:57Z")

</div>

Hola,

We’re having a problem with Internet Explorer not rendering .png files  
properly.

We’re using a Javascript fix right now, but it’s failing when it gets to  
an image that has been generated by a rails image tag

(e.g. the code: \<%= image\_tag myimage %\> spits out:  
src=“images/myimage.png?1184877097”) - and that doesn’t render properly  
in IE.

Here is my question:  
I’m wondering if there is a way to turn off whatever tacks on the  
1184877097.

(I think that’s there to prevent image caching).

Have other people had this problem? What other solutions are out there?

Thanks,  
Dustin

---

<div class="post-metadata">

**Author:** ![dkanders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7bcc69/32.png) [@dkanders](https://www.ruby-forum.com/u/dkanders)\
**Post date:** [July 26, 2007, 12:45am UTC](https://www.ruby-forum.com/t/png-fix-not-working-with-unique-identifiers-on-image-paths/110393/2 "2007-07-26T00:45:51Z")

</div>

> in IE.
> 
> Here is my question:  
> I’m wondering if there is a way to turn off whatever tacks on the  
> 1184877097.
> 
> (I think that’s there to prevent image caching).
> 
> Have other people had this problem? What other solutions are out there?

We’ve been using this in an onload handler and it has worked for us.  
Not  
sure where it came from, but PNG are transparent and we haven’t had to  
muck with the ?12345 part at all.

function correctPNG() // correctly handle PNG transparency in Win IE 5.5  
or higher.  
{  
for(var i=0; i\<document.images.length; i++)  
{  
var img = document.images[i]  
var imgName = img.src.toUpperCase()  
if (imgName.match(/.PNG/))  
{  
if ( img.src.indexOf(“[google.com](http://google.com)”) != -1 ) {  
continue;  
}  
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 = “\<img " + imgID + imgClass + imgTitle  
+ " style="” + “width:” + img.width + “px; height:” + img.height

- “px;” + imgStyle + “;”  
+ “filter:progid:DXImageTransform.Microsoft.AlphaImageLoader”  
+ “(src='” + img.src + “', sizingMethod=‘image’);" /\>”  
img.outerHTML = strNewHTML  
}  
}  
}
