It slices, it dices, it inserts your (or someone elses) latest flickr photos into your page using absolutely no document.write() calls, guaranteed.
Firstly, include the javascript - replace USERNAME with the flickr username.
<script type="text/javascript" src="http://flickr.m.ac.nz/dom-badge/remote/?user=USERNAME"></script>
Secondly, there are two ways of using it:
If your needs are simple, all you need is an element that has an ID, e.g.
<div id="photos"/>Then call:
FlickrTools.set1.drawInto("that ID");If your needs are more complex, call FlickrTools.set1.drawPhotos directly. You'll need to pass it one parameter - a call back function that will give you the images. Here is an example - it's basically what drawInto() does, but, well, yeah.
FlickrTools.set1.drawPhotos( function(aSrc, aUrl, aTitle) { var theLinkEl = document.createElement('a'); theLinkEl.href = aUrl; var theImageEl = document.createElement('img'); theImageEl.src = aSrc; theImageEl.title = aTitle; theLinkEl.appendChild(theImageEl); document.getElementById('photos').appendChild(theLinkEl); } );
Can I use it more than once in a page?
Why yes you can. Add a &set=something to the first script tag, and replace set1 with the same (e.g. set2), as long as it's a valid javascript variable name, you'll be fine.
Demo (using .drawInto())
Why?
I'll accept this isn't as easy as the Flickr one. It doesn't offer you as many options (though feel free to contact me if you want some). However it should work just fine and dandy in Firefox et. al. that treat XHTML as XML.
Feel free to use this. Flickr may come along and do something like this themselves. Until then I'm filling a very small gap.
The Source
The current version (v2, if you like) is now delivered as part of a ruby on rails app that powers most of my site. You can download the controller, model (+sql) and view. Again, released under the MIT License. You'll need to bring your own Ruby on Rails app to make much use of it, though I'm sure you could translate it into Camping fairly easily.
The original (PHP) source is available (under the MIT License). You'll need Phlickr as well, which means you'll need PHP5. Don't know what this bit means? Don't have a server that'll do this? Never fear, you can just use it from here.
