treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Flickr API

  • I am adding a Flickr stream to a website using Jquery and JSON as shown in Chris' tutorial http://css-tricks.com/build-your-own-social-home/.

    	$.getJSON(\"http://api.flickr.com/services/feeds/photos_public.gne?ids=52723107@N00&lang=en-us&format=json&jsoncallback=?\", function(data){
    $.each(data.items, function(index, item){
    $(\"<img/>\").attr(\"src\", item.media.m).appendTo(\"#flickr ul\")
    .wrap(\"<li><a href='\" + item.link + \"'></a></li>\");
    });
    });


    At the moment it is showing the last 20 pictures taken. Is there anyway to configure how many results actually show ( i only need about 5 or 6).

    Thanks
  • I kinda wondered about that too, and then never found a good solution. I think I approached it from the angle that there is probably a parameter you can pass with the URL to limit the responses, but I never found one. Another angle to the problem would be to ditch the "each" loop and only loop through a set number of times, although I couldn't tell you exactly how to do that since I'm a bit of an amateur myself when it comes to all this stuff.
  • you just add an if statement at the end and you'll be able to control the amount of pix

    ;if ( index == 6 ) return false;

    for 5 pictures.

    works like a charm,

    hope it helps Charles

    PS Chris the footer OH MY ... siiiiiiiiiiick!!!!
  • Thanks pab!

    Also must agree, Chris, the footer is amazing - i love the twitter spaceship.
  • My Pleasure Charles, let me know if you need anything else
  • Is there any way of getting random images from your Flickr stream?