Skip to content

Instantly share code, notes, and snippets.

@DimitarChristoff
Created March 21, 2011 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DimitarChristoff/879276 to your computer and use it in GitHub Desktop.
Save DimitarChristoff/879276 to your computer and use it in GitHub Desktop.
mootools
(function() {
document.getElements('img[src$=png]').each(function(img, i) {
var oldId = img.id;
img.setProperty("id", "old"+i);
var imgID = "id='clone" + i + "' ";
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;
$("clone"+i).cloneEvents(img).setProperties(img.getProperties('alt','rel','title','id'));
}); // each
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment