Sep
12
24

Random Photo Returns

Meta, Photolog

The random photos are back. I wrote a quick hack to loop over every photo in every album and read its relevant info into a MySQL table. Now instead of taking a few seconds to get a random photo using the Gallery data stores, it uses a single query and takes a millisecond. Long-time visitors to the site remember that the random image in the corner has always been one of my favorite things about this site, but as the photolog grew to a thousand, two thousand, and then nine thousand images it slowed down more and more. I had to start caching it so it would change once every 15 seconds, then every minute, then every 5 minutes, and then I just manually rotated it for a while. Finally I put the random image out of its misery.

Now it’s fully dynamic, every page you view is completely unique, just like you.

(There goes my bandwidth.)


24 Comments

  • Dale September 12, 2004 @ 7:12 am

    hehehehe F5 F5 F5…..

  • MaThIbUs September 12, 2004 @ 7:23 am

    There goes my bandwidth.

    Indeed! Nine thousand photos is a whole lot, I can imagine those take up a lot of server space. (Poor me, I’ve only got 75 MB on my server, with a bandwidth limit of 5 GB…)

  • Observer September 12, 2004 @ 7:24 am

    @Dale:Hehe, nice one!
    @Matt: Another big PRO for RSS et. al., don’t you think?

  • Scott September 12, 2004 @ 7:33 am

    Awesome Matt! Bandwidth, Smandwidth!

  • markku September 12, 2004 @ 10:23 am

    Nine thousand photos? Wow. Maybe you should have your randomizer provide a unique photo when a visitor comes back, without serving a photo twice. Until all 9000 photos are delivered for that visitor. Then another shuffle, and the same cycle all over again…

    Just another stupid idea. ;)

  • Indranil September 12, 2004 @ 10:53 am

    Hey Matt, ever heard of “limited bandwidth”!!

  • Rob Mientjes September 12, 2004 @ 11:28 am

    Hurrah! I love the random image, and I missed it since it went out of rotation (well duh). Thanks for putting it up again.

  • Randy Peterman September 12, 2004 @ 1:43 pm

    Remember, you’re unique, just like everyone else.

  • Jonathan Stanley September 12, 2004 @ 1:52 pm

    Thought bandwidth was a commodity which one doesn’t have to worry about anymore? ;)

    Anyhoo… good to see it back as I’m using Gallery’s native “Random Block” feature on a friend’s site since June-ish, and finally gave in and started using it on my own blog just a couple weeks ago.

    F5 F5 F5 F5 F5 :D

    /me feels dirty in misusing <code> when he should have used <kbd>…

  • Daniel September 12, 2004 @ 2:53 pm

    I must say, 9,000 images is alot. It’s very good to see the random images up again. I did miss that space up there in the corner. Yay for photos!

  • Jesus Vargas September 12, 2004 @ 3:09 pm

    And the code? Is it free? LOL. ThX

  • Matthew Wilcox September 12, 2004 @ 3:50 pm

    Wow, so there -is- a reason you’re URL is photomatt.net
    Always wondered why the ‘photo’ bit

  • Matt September 12, 2004 @ 3:52 pm

    Reload to your heart’s content, that is what it’s there for. I use a lot of bandwidth, but it’s still a fraction of what’s available. Besides, what is the point of bandwidth if you don’t enjoy it?

  • Josh Street September 12, 2004 @ 5:06 pm

    Wow. That’s a bit kah-razy… I want that kinda bandwidth to throw around!! ;)

    Very cool.

  • Jeremy September 12, 2004 @ 6:03 pm

    yay! It’s back! :D

    Thanks Matt! I enjoyed this feature as well.

  • Matt Read September 12, 2004 @ 6:13 pm

    Looks very good Matt. And being on dial-up there nice and small and don’t add much to load time. Nice.

  • elissa September 12, 2004 @ 7:32 pm

    rockin’.

  • Stephan Segraves September 13, 2004 @ 9:04 am

    Very cool. Glad to see it back!

    Are you dynamically thumbnailing the photos before they are displayed?

  • Matt September 13, 2004 @ 9:10 am

    Nope the thumbnails are generated when I upload the picture.

  • Julie September 13, 2004 @ 1:09 pm

    Ah, the random photo. Beautiful. :)

  • Christine September 13, 2004 @ 9:39 pm

    Yeah!!! I’ve missed the random photos. It’s really strange to load up your site and see myself there though!

  • Carla November 3, 2004 @ 5:40 pm

    Does it ignore Gallery-hidden images and albums, per chance?

  • Matt November 3, 2004 @ 6:49 pm

    Yes it does.

  • Carla November 7, 2004 @ 2:54 pm

    Groovy. Tunes. Thanks, Matt! I use Gallery to organize as well as to present, and I don’t think anyone wants to be bombarded with random clip art or blobs. :D

Share Your Thoughts