Update to Pulling Flickr RSS Feed Images

Posted on Mar 21, 2007

Ok, so no sooner do I go and write my first Edge article than Flickr goes and makes the code I present break by changing their naming convention on newly uploaded images. First, this was first pointed out to me by Glenn Gervais who provided a different solution. Basically, it appears that on newly uploaded images the auto-generated names now differ in more than the _o or _m in the filename, so it can't be achieved with a simple replace(). I decided that since the "description" field returned by Ray's RSS.cfc has the medium sized image within it, I could just use some regex to strip it out like so:

<cfinvoke component="rss" method="getEntries" returnvariable="pics" xmlData="http://api.flickr.com/services/feeds/photos_public.gne?id=74682459@N00&format=atom" /> <cfset randPic = randRange(1,pics.recordCount) /> <cfsavecontent variable="regex"><img.*/></cfsavecontent> <cfset findImage = REFindNoCase(regex,pics.description[randPic],1,true) /> <cfoutput>#mid(pics.description[randPic],findImage.pos[1],findImage.len[1])#</cfoutput>

This will actually output a random image from the feed since it strips the entire image tag, which is what I use on my about page.

Comments

Claire Hello!

I am looking for a script so that I can have a random flickr image on my website. Your feed one looks great. But as they are on a feed they are rather small images. Is there any way of having random images from the main photos?

It would also be great if their titles were pulled in also.. Any ideas? I can't seem to find anything around anywhere?

many thanks
Claire

Posted By Claire / Posted on 02/26/2009 at 9:52 AM


Brian Rinaldi @claire - actually, I am specifically filtering for the small image because that is what I want. If you go to your feed URL you will notice that it includes a list of media files for each entry that is of the full size image.

Posted By Brian Rinaldi / Posted on 02/26/2009 at 9:57 AM


Write your comment



(it will not be displayed)





About

My name is Brian Rinaldi and I am the Web Community Manager for Flash Platform at Adobe. I am a regular blogger, speaker and author. I also founded RIA Unleashed conference in Boston. The views expressed on this site are my own & not those of my employer.