This post is pure technical self-indulgence, so please skip it if you don’t want to read my complaints about image gallery handling in WordPress, and the pain of writing a better one in PHP.
Let’s start slowly…a photograher’s website is probably going to have a lot of photos…like…thousands of photos. WordPress is the most popular content management software with 33% of *all* websites being powered by WordPress. This doesn’t mean that WordPress is the best blogging software – just the most popular. I have done just enough WordPress software development to know that I never want to do it again.
WordPress has native gallery handling functionality, and there are a huge number of third-party gallery plug-ins available, but all suffer from (what I regard as) a few fatal flaws.
- You must upload the photos via a clunky and slow web interface, and enter any metadata (photo titles/captions, etc.) one photo at a time through the same interface.
- Information about all media items is stored in the wp_posts database at the time of upload. If you want to (for example) change a file name, or add EXIF metadata to a photo, you are probably going to have to delete the photo and upload it again.
- Finding and selecting photos in the media library is easy when there are tens of items, but gets a little tricky when there are thousands.
So it really boils down to two problem areas: WordPress galleries are not well suited to handling photos in bulk, and the bigger conceptual problem – that the wp_posts database is treated as the definitive source of information about the photo (photo descriptions, etc.).
What I decided that I needed was:
- A file-based gallery, so I can easily upload photos in bulk using SFTP instead of uploading via a clunky web browser interface.
- To have the photo file as the definitive source of information about the photo (rather than a table in the WordPress database), so that the photo description and camera information (lens, aperture, ISO, shutter speed) can be extracted from the photo EXIF metadata rather than entered into the WordPress database via a web form. This makes my photo editing software (Lightroom) my system of record, so I only have to enter this information once, and the information stays with the photo, rather than my website (in case someone saves a copy of the photo).
- To make changes to photos easier (updating EXIF metadata, changing image resolution, renaming files, changing your watermark, etc.). Updates are done via SFTP by just uploading a new file.
Suddenly this meant was that I was programming in PHP (yuck!) for WordPress (double yuck!). I needed to write code to:
- Generate thumbnails of different sizes (with ImageMagick)
- Extract EXIF metadata from photos and write to an intermediate file
- Determine the display order of photos (to override display in alphabetical order)
- Display photo and caption/metadata (WordPress template hacking)
- Display a feature image for the gallery (more template hacking)
I can’t claim that writing code to manage galleries the way that I want them was the best use of a day of my time, but I’m happy with the outcome, and I hope it motivates me to post more photos.
Leave a reply