Skip to content

Instantly share code, notes, and snippets.

@ericf
Created April 30, 2010 00:37
Show Gist options
  • Select an option

  • Save ericf/384518 to your computer and use it in GitHub Desktop.

Select an option

Save ericf/384518 to your computer and use it in GitHub Desktop.
Y.datauri('http://example.com/foo.png', function(fooDataURI){
Y.one('body').append(Y.Node.create('<img/>').set('src', fooDataURI));
});
Y.datauri('http://example.com/foo.png', 'http://example.com/bar.png', function(foo, bar){
});
Y.datauri(['http://example.com/foo.png', 'http://example.com/bar.png'], function(datauris){
// datauris is an array because array was passed in
});
Y.datauri('/baz.jpg', function(bazDataURI){
// generate absolute reference to baz using window.location and/or <base href="" />
});
Y.datauri(['http://example.com/foo.png', 'http://example.com/bar.png'], {
on : {
data : function (datauris) {
// support chunking requests to YQL but getting responses fast
// { 'http://example.com/foo.png': 'sadjfhklsajdf239487asdfhkj' }
// have to key the data coming back because we're not sure the order requests will return in
// the key for the dataURI is the corresponding passed into the function.
},
complete : function (datauris) {
// all data URIs have been loaded and generated, datauris is an array
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment