z e t a l l i t e
 
Toggle Music
 

Grab Flickr Photos with Javascript!

  •  

Michael at mlcastle.net made a nice script called flickr-dom.js. It parses the JSON returned by flickr and output XHTML and DOM compliant code. If that’s all alien to you, don’t fear! Just read on… using it is no where as hard :)

I’ve put his script together with some css which can be download here.

To grab the images you want from flickr, all you need to do is point the the correct feed. To do this, locate line 27 in flickr-grabber.html. You should see this URL:
http://api.flickr.com/services/feeds/photos_public.gne?tags=starcraft&format=json
This is the feed where the images are being grabbed from. As you can see, there is a part that says “tags=starcraft”. That simply means… grab all public images on flickr that is tagged “Starcraft”.

To narrow the search, and get images tagged with both “Starcraft” AND “Warcraft”, add to that URL more tags separated by commas.
http://api.flickr.com/services/feeds/photos_public.gne?tags=starcraft,warcraft&format=json

To broaden the search and get images tagged either “Starcraft” OR “Warcraft”, add to the URL “&tagmode=any”.
http://api.flickr.com/services/feeds/photos_public.gne?tags=starcraft,warcraft&tagmode=any&format=json

The online documentation for flickr URL feeds can be found here.

9 Responses to “Grab Flickr Photos with Javascript!”

  1. My Pakistani friend did something too. :)

  2. yea that uses ASP. this is pure client-side… javascript only.

  3. means doesn’t need a php or asp environment… you can even view it off your desktop for that matter :)

  4. Okay I didn’t try it but just curious, does it use document.write like the standard flickr badge does? If not, it should be compliant in application/xhtml+xml MIME type, right?

  5. not sure what you’re asking heh… but it doesn’t use the javascript document.write() check out http://mlcastle.net/flickr-js-dom-json.html

  6. good to see you sharing knowledge in your blog. =) keep it up. oh gosh, why am i not sleeping now????

  7. !!! /slap

  8. @pk: Aww, I should have found out about this earlier when I was looking for an alternative. Now I’m using PHP to generate the photos. Thanks for sharing anyway!

  9. […] Pior to this, i’ve posted on how to “Grab Flickr Photos with Javascript!“ […]

Leave a Reply