views:

33

answers:

2

Hi,

I've gone through the http://css-tricks.com/examples/BuildYourSocialPage/ which is great, but I just want to customise the amount of Flickr images it pulls in(6) with the API.

I know I could set a div with overflow:hidden to show the desired amount, but I don't want the code to be hacky.

Can anyone help?

Also I'd like to display my last.fm latest albums, does anyone know where you can get the API to do this?

Thanks

Paul

P.S I know you can get premade plugins and do all this through wordpress, but I don't want to do that. It's just a small expirmental page to test ideas.

+1  A: 
  1. The Flickr Feeds Service do not allow such parameterization, but you could change the JavaScript code that displays them to filter only the first 6

    $.each(data.items, function(index, item){
            if (index < 6){
              $("<img/>").attr("src", item.media.m).appendTo("#flickr")
              .wrap("<a href='" + item.link + "'></a>");}
          });
    
  2. Last.fm Api => user.getWeeklyAlbumChart

Gaby
Thanks this is a what a quick fix that I was aiming for… for now! :)
Paul
+1  A: 

One thing to note is that the example page is not actually using the full-on Flickr API -- it's using a simple feed to retrieve the photos.

This gives less control -- I believe the number of items from these feeds are fixed at 20.

I can think of a few different ways you can go from here.

You could:

  • Filter the results you get back in JavaScript to throw away the unwanted images. Probably easiest, but a bit inelegant.
  • Use the Flickr API instead, which will allow you to set limits, but will require an API key, and is probably easier server-side.
  • Use something like YQL to do your Flickr search and limiting, and parse those results instead. I created an example query here: http://y.ahoo.it/ZzopXNiw YQL allows JSONP, so you could still use this cross-domain, I believe, though you'd need to change the receiving Javascript to match the new format. There's an excellent example of using YQL to search Flickr on the Wait till I come site.
  • Create a Yahoo Pipe to truncate the feed for you, perhaps grabbing it as RSS, feeding it through the Pipe's RSS-fiddling functions, and spitting out JSONP -- I believe this is doable in Pipes.

YQL in particular is very cool and very powerful, especially when dealing with Yahoo's own services like Flickr. Seeing as you say you're playing with ideas, I figured I'd give you some interesting ones to play with :)

Matt Gibson
Great thanks for this, really opensup my options and I think when I have more time I'll delve into the API properly. Thanks :)
Paul