The past few hours I have been pretty geeky. I’ve been looking into Flickr’s API (application programming interface) and how I can monkey around with it and PHP. What did I want to accomplish? At the beginning I didn’t really have a goal, I wanted to see what I could do with it, how I can access my photos and from there I would figure out something fun to implement.
Well it seems I have figured out something cool. If you’ve noticed the larger photo on the header of my page, the one above the Flickr RSS thumbnails, it is a bit more dynamic than usual. Previously I had 5 (I think) header images that I created in Photoshop and was using PHP to randomly insert on when the page refreshed. Now I can be a bit lazy at times and I haven’t looked at updating those 5 photos in a while, so I was thinking how I could incorporate my Flickr photos with my website in order to help give my photography a bit more exposure.
So what’s different? Go ahead and refresh the page, it should show a random photo of mine from Flickr. Though there is a catch, it isn’t the fastest system yet and it doesn’t always show something cool. Let’s see if I can explain the functioning behind how it currently works. I might have a revision or two, but for now I think it’s pretty cool!
- Pull the last 400 photos from my Flickr Photostream (pulls XML data)
- Select a random photo using PHP’s rand() function and create URL for photo
- Check to see if it is in landscape or portrait orientation, discard if it’s portrait
- Select the middle third of the photo, remember the “Rule of Thirds” for photography? Hopefully this is the more interesting portion of the photo. If not, tough luck! Typically my photos are 800×533 on Flickr
- Create a new 850×118 jpeg image and copy random photo into its placeholder, resize to width if needed
- Display photo in all its glory as my header image
Not bad for a couple of hours of work. Either way it allows for a more dynamic header and some more ‘freshness’ too!
I am looking for your feedback on this! Is it slow to load? Do the photos suck? Is it a cool idea? Is it random enough? What do you think?
I can just sit here and refresh my screen all day looking at whatever random photo is pulled from Flickr.