Skip to content

Instantly share code, notes, and snippets.

@poppen
Created January 6, 2011 05:57
Show Gist options
  • Save poppen/767587 to your computer and use it in GitHub Desktop.
Save poppen/767587 to your computer and use it in GitHub Desktop.
function jsonFlickrApi(data) {
var photos = [];
var randOrd = function() {
return (Math.round(Math.random()) - 0.5);
};
$.each(data.photoset.photo, function(i,p) {
var get_url = function(url) {
return url;
};
var get_alt = function(title) {
try {
return p.title;
} catch(e) {
return "";
}
};
photos.push({
src: get_url(p.url_m),
alt: get_alt(p.title),
});
});
photos.sort(randOrd);
$("#dump").append($.dump(photos));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment