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
- Install Lazyest Gallery.
- 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.
- 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:
- Now, copy one of your photo directories from Dropbox to that Gallery Folder with FTP or SCP or whatever.
- 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.
- 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
- Let’s assume you’re hosting your WordPress on a Linux server, because you’re a clear-thinking person.
- Install Dropbox on your server. That’s as simple as downloading it from the Dropbox site.
- 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.
- For clarity’s sake, I created a
Public Photosfolder under
Publicin 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 Photosis 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.
- Configure Dropbox to exclude everything except the Public Photo folder you’d like to publish. You can use
dropbox.py excludefor 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
slides/ that you’ll want to preserve. So let’s use unison, which is made for two-way sync’ing.
Phase III: Unison
- Install Unison. It’s in EPEL and wherever it is that Ubuntu folks get things.
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
Set up a cron job for the dropbox user:
*/5 * * * * unison -terse
- So every 5 minutes, we’re going to make the Gallery Folder look like our
/Public/Public Photosdirectory 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.