I’ve mentioned this before, but I thought I’d revisit it since I’ve recently rolled out a few changes.
In the last year or so, 500px has exploded to become the “serious” alternative to Flickr—a place where you show off your best work while not being crowded out by the kinds of people on Flickr that upload every lame snapshot of their kids or dump their entire CF or SD card into their stream everytime they come back from an outing.
Unfortunately, one of the big problems with 500px is that there’s no “good” way to randomly view images, save for a link at the bottom of their homepage inviting you to “StumbleThru 500px”, which simply uses user-submitted links on third-party service StumbleUpon.
I found this to be inadequate, as it only relied on photos that users had bothered to “Stumble”. This meant that the number of images were somewhat limited as well as confined to mostly the more popular images—ones that the hive mind of the 500px viewership community had decided were “the best” and worthy of linking to. After a few clicks on the Stumble button, I found that I was getting the same few images over and over again—some of them were even months old.
What I wanted to do was see truly random images from 500px, so I set out to make a tool to do the randomizing for me.
My first iteration was simple. Since, at the time, 500px didn’t have a publicly-exposed API, I had to be “kludgey”. A bit of poking around revealed that 500px simply numbers photos sequentially as they are uploaded—in fact, you can easily go see the first photo uploaded publicly thanks to the ridiculously-easy-to-reverse-engineer URL convention of http://500px.com/photo/<number of photo>. This made it extremely easy to create a php application that would simply generate a random number between 1 and whatever the largest number used is. The php code is easy:
$iPic = mt_rand( 1 , $iMax );
Where $iMax is whatever the largest number used is. Since I didn’t want to have to bother writing an overly-long script to figure out what the latest number used was, I’d simply manually update $iMax every couple of days with the photo ID of the first image on 500px’s Fresh page.
In my app, I embedded an iFrame to hold the photo’s page while the app acted as a wrapper around it, keeping the “Randomize” button and “Permalink” link visible at all times. And this worked great, but I wasn’t happy. I quickly found that while 500px has tons of great work on it, there’s a lot of cruft. Especially amongst the older photos submitted before the community really “took off”. What I really wanted was to be able to randomly browse photos that were of a bit higher quality and were on the newer side (and this, I suppose, is where my application lost it’s complete randomness). Unfortunately, this wasn’t really possible at the time, so I let the project sit on the backburner for a while.
Then 500px opened up its API. And I leveraged it. I quickly figured out how to use JSON queries to return arrays of recent photos in the Fresh, Editors’ Choice, Upcoming and Favorites categories. Not really caring about Fresh since that’s the initial “dumping ground” for everything uploaded, I concentrated on the other categories. I quickly produced some code that queried the API and returned a random photo from the user’s choice of categories, replacing my previous code that haphazardly propelled you around 500px and instead allowed you to randomly view more-curated photos.
So, there you have it, the story behind my 500px Randomizer. Feel free to use it all you want; just keep in mind that it’s still a work in progress and if you find any bugs, feel free to send me an email at firstname.lastname@example.org to let me know.