public
Last active

Feature detect base64 support for images in mootools

  • Download Gist
Browser.features.base64.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// http://www.jsfiddle.net/5JT45/10/show/
 
(function() {
Browser.Features.base64 = null;
var callback = function() {
Browser.Features.base64 = this.width == 1 && this.height == 1;
// alert(Browser.Features.base64); // true || false
};
var img = new Image(), element = document.id(img) || new Element("img");
element.onload = element.onerror = element.onabort = callback;
// 1x1 px gif to test with
img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
})();

is it humanly possible to make more mistakes on a less-than-10 lines snippet? hopefully it's now done and dusted.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.