manu

Use Google Photos as WordPress post attachment gallery

My dad doesn’t know about computers at all. Although he did a few lessons decades ago, he never got really into it. But he knows how to use a smartphone these days. It’s not that hard for him anymore, after using such a device for years now. He also makes a lot of pictures one needs to handle first. For this very reason I got him to use Google Photos. I showed him how to manage the pictures he took and created an album he wants to show off as gallery on his website.

How it works

The script uses wp-cli to deal with WordPress and takes 2 arguments (required):

The bash script

The bash script is looking for an option stored in the database every 30 seconds. If it is missing, it will download all the images with the Google Photos API and renames them immediately to take care of the order. All the images attached to the post will be deleted, before they will be uploaded again. It will also flush the cache and notify by mail once the work is done. The post just needs to include the default gallery shortcode without any options then.

Supervisord config

The site is hosted on uberspace so I run the script as service with supervisord.

WordPress files

Now you only need to delete the option in the database every time the album got changed.

With all these images, the media library sure looks messy. So I just hide all the uploads by other users. It also prevents me to use these images in other posts as they will be deleted next time the album got updated.

I also like to use the HTTP Shortcuts for Android app and create a widget on the home screen, which will do an HTTP request.