Skip to content

Instantly share code, notes, and snippets.

@b3457m0d3
Created May 18, 2012 06:25
Show Gist options
  • Save b3457m0d3/2723556 to your computer and use it in GitHub Desktop.
Save b3457m0d3/2723556 to your computer and use it in GitHub Desktop.
$(document).ready(function(){
//setup info
var id = "";//<- You user id
var num = 1;//<- How many images to pull in
// Grab JSON from Flickr
$.getJSON("http://api.flickr.com/services/feeds/groups_pool.gne?id="+id+"&lang=en-us&format=json&jsoncallback=?", displayImages);
//
function displayImages(data)
{
// Choose where in the feed to start, 0 is latest
var iStart = 0;
// Reset our counter to 0
var iCount = 0;
// Start putting together the HTML string
var htmlString = "<ul>";
// Now start cycling through our array of Flickr photo details
$.each(data.items, function(i,item){
if (iCount > iStart && iCount < (iStart + num + 1)) {
var sourceSquare = item.media.m;
// Here's where we piece together the HTML
htmlString += '<li><a href="' + item.link + '" target="_blank">';
htmlString += '<img src="' + sourceSquare + '" alt="' + item.title + '" title="' + item.title + '"/>';
htmlString += '</a></li>';
}
// Increase our counter by 1
iCount++;
});
// Pop our HTML in the #images DIV
$('#images').html(htmlString + "</ul>");
}
});
//you should set the images to the proper size with CSS
//and there needs to a div with the id #images in the DOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment