Present the most recent image from a Flickr imageset

The start page on my main site present the latest image from a flickr set I upload to from my mobile phone. Here’s how it’s done:

<img src="img/pictures/mobilecamera.jpg">

<script type="text/javascript">
 $(document).ready(function () {
     $.getJSON("http://api.flickr.com/services/feeds/photoset.gne?set=xxxxxx&nsid=yyyyyy&format=json&jsoncallback=?",    
     function (data) {
         $.each(data.items, function (i, item) {
             $(".lastflickrimage").attr("src",item.media.m);
             $(".lastflickrimagetitle").append(item.title);
             if (i == 0) return false;
         });
     });
 });

This shows a default image, in my case a mobile phone, and switch it to the latest flickr image. You can use the same code if you;

    • Change xxxxxx to the flickr set id. You can find the id when mouseover a set on the organizr page.
    • Change yyyyyy to the flickr user id. Find the id here.

Trackback URL: https://codeblog.silfversparre.com/2011/11/how-to-present-the-most-recent-image-from-a-flickr-imageset/trackback/