Created
May 4, 2013 15:22
-
-
Save benjamincharity/5517798 to your computer and use it in GitHub Desktop.
Modernizr test for datauri (base64 encoded images).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// data uri test. | |
// https://github.com/Modernizr/Modernizr/issues/14 | |
// This test is ascynchronous. Watch out. | |
(function(){ | |
var datauri = new Image(); | |
datauri.onerror = function() { | |
Modernizr.addTest('datauri', function () { return false; }); | |
}; | |
datauri.onload = function() { | |
Modernizr.addTest('datauri', function () { return (datauri.width == 1 && datauri.height == 1); }); | |
}; | |
datauri.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment