Right-click image uploads for static sites on macOS
Aug 13 2017
Quick and dirty post on something cool I’ve just learned.
While putting together this blog, I’ve wanted an easy way to add an image to a post. I’ve long appreciated Dropbox’s auto-uploading screenshots, and wanted something that easy. Here’s how I did it:
Create an “upload” script
(“Upload” is a bit of a misnomer here – the actual uploading is done by the blog’s rsync deploy. Still, it’s the closest match to how I thought of it when writing the script.)
Normally I’d write this in bash/zsh, but in this case I think Python’s easier to read:
Create an Automator service to call that upload script
- Open up Automator (should be built-in on macOS)
- New -> Service
- Library -> Actions -> Utilities -> Run Shell Script
- Service receives selected files or folders in Finder.app
- Pass input as arguments (don’t forget this!)
- Create a shell script that calls your
upload.py
file
- Save it as something like “Upload to Blog Static Dir”
- Done! Right-click an image -> Services -> Upload to Blog Static Dir and watch the magic happen!