The Lazy Man’s WordPress Photo Gallery with Dropbox

I keep my photos on Dropbox, but I want to post them for everyone to see. Managing online photo galleries like Facebook, Flickr, Picasa, and friends is really tedious – and I don’t like how hard it is to get those photos back from those services. I could send people to the Dropbox pages, but that wouldn’t have the look and feel of my website.

What I really want is to dump a bunch of photos into a Dropbox folder and be done with it.

So obviously, I have to do this myself.

I found the Lazyest Gallery plugin for WordPress, which is really great. You dump a bunch of photos into a directory on your server, and it does the rest. This is a great start.
So that’s phase 1.

Phase I: Set up Lazyest Gallery

  1. Install Lazyest Gallery.
  2. Lazyest Gallery will ask you to choose a directory where your photos will live. They call it the “Gallery Folder.” That directory is where we’ll dump stuff from Dropbox, so remember your choice.
  3. Lazyest will also ask you to choose a Page to anchor your photos. I created a page called “Photos”, but you can call yours whatever you like. You can always change your mind later. It will offer to insert the necessary magic to make that page work as your Lazyest Gallery, go ahead and say yes to that. You can always change your mind later:Lazyest Gallery configuration
  4. Now, copy one of your photo directories from Dropbox to that Gallery Folder with FTP or SCP or whatever.
  5. Spend about 7 hours tinkering with options to make the Lazyest Gallery pages behave how you want. I enabled Lightbox and cached thumbnails in the “Thumbnail Views” section, disabled slideshows in the “Slideshow Views” section, and enabled permalinks under “Advanced Options”. You can do whatever you want, though.
  6. Spend about 5 hours tinkering with CSS to make the Lazyest Gallery pages look how you want. On my theme’s stylesheet you can see how I made Lazyest match my version of the Pinboard theme.

You now have a fully-functional Lazyest Gallery install which will magically use whatever photos you drop into that Gallery Folder.

The next phase is to get Dropbox all hooked up.

Phase II: Dropbox Setup

  1. Let’s assume you’re hosting your WordPress on a Linux server, because you’re a clear-thinking person.
  2. Install Dropbox on your server. That’s as simple as downloading it from the Dropbox site.
  3. Configure Dropbox for a mortal user on your server. You can create a user just for this purpose, or use another mortal account. Just don’t use your web server or root account for this. That’s be a security problem.
  4. For clarity’s sake, I created a Public Photos folder under Public in Dropbox. Because it’s in /Public, I won’t forget it’s available to the whole world. I threw a couple galleries in there for starters. Because /Public/Public Photos is different than your original Photo directory, you can do smart things like publish just a subset of some photos, publish downsampled/smaller versions, add watermarks, etc., without altering your originals which are still safe and sound in the other, private, Dropbox folder.
  5. Configure Dropbox to exclude everything except the Public Photo folder you’d like to publish. You can use exclude for that. If you don’t, you’ll get many GBs of stuff you don’t care about dumped on your server.

Now you have the Gallery running and your photos sync’ing to your server.

You will have an urge to create a symlink between the Gallery Folder and the relevant Dropbox folder. Don’t do that. If it works, it’s a security problem because you’ll have given a web server write access to your entire Dropbox folder.

Your next urge will be to set up a cron job to rsync the Dropbox stuff over to the Gallery Folder. That’s a good idea, but Lazyest Gallery adds stuff like a captions.xml file and directories for cached images, like thumbs/ and slides/ that you’ll want to preserve. So let’s use unison, which is made for two-way sync’ing.

Phase III: Unison

  1. Install Unison. It’s in EPEL and wherever it is that Ubuntu folks get things.
  2. Create a unison configuration for the Dropbox user. It’s going to look a lot like this:
# Roots of the synchronization
root = /path/to/public/photos/on/dropbox
root = /path/to/gallery/folder

# disable logging
log = false

# Some regexps specifying names and paths to ignore, if you like
# ignore = Name slides ## ignores all slide directories
# ignore = Name thumbs ## ignores all thumbnail directories

# Ignore user and group ownership, so we have the correct permissions on both ends
owner = ignore
group = ignore

# keep unison quiet
batch = yes
  1. Set up a cron job for the dropbox user:
*/5 * * * * unison -terse
  1. So every 5 minutes, we’re going to make the Gallery Folder look like our /Public/Public Photos directory on Dropbox. Boom.

Fire up unison, and watch in amazement as the photos you dump into the /Public/Public Photos folder end up appearing beautifully on the Photos page of your website.

3 thoughts on “The Lazy Man’s WordPress Photo Gallery with Dropbox

  1. Thank you for your post about Lazyest Gallery. I had never thought about synching with dropbox. It’s awesome.
    BTW the gallery markup for Lazyest Gallery is quite messy indeed. That’s why I have rewritten the plugin from scratch. It will live on as Eazyest Gallery.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s