A plugin to use Google photos

Using images is part and parcel of any website. It’s easy enough to reference and build into jekyll local and remote images. What I really wanted was a way to link to my images held on google photos. But (surprise!) Google hides them behind thier own Google Photos app with obfusicated URLs. After some investigation I wrote a jekyll plugin to retrieve my own images from Google Photos.

jekyll_googlephotos provides two jekyll tags:-

googleimage and include_fromcache

googleimage usage:

In a Google Photos gallery generate a shared link such as

https://photos.app.goo.gl/48WcPC4DHKv1WwXu9

The base portion is specified in the _config.yml:

googlephotos:
  base: "https://photos.app.goo.gl/"

and the variable portion (eg 48WcPC4DHKv1WwXu9) is the parameter to googleimage.

{% capture img %}{% googleimage {{target}} %}{% endcapture %}

The captured variable is the full obfusicated URL to the actual image without all the google photos guff eg

https://lh3.googleusercontent.com/pw/AP1GczPozK3H9NoG7U3xYuwwju9bruvaDQK3yFMfXUVDpGoi5wIB2zr....

and this can be used as any other URL to an image. Using the shared link to a single image works in the same way - its the same Google Photo app.

include_fromcache usage

This part of the plugin will create HTML snippits according to the _config.yml and templates and store them in the jekyll build cache. Those snippits can be included in posts as desired. This allows for some fragments that are quite time-consuming to be created once and used across builds. Specifically to create an art gallery layout which requires fetching multiple images from Google Photos.

{% include_fromcache artgallery %}

The fragment and its key (‘artgallery’) is defined in _config.yml:-

googlephotos:
  generate:
    - template: artgallery
      data: art
      clazz: Reading::GPGartgallery

The template is at _includes/googlephotos/artgallery.html. The data is from _data/art.csv. The clazz specifies a Ruby class that has the task of processing the data into the template.

The end result is a gallery of relative scaled images in a flexbox layout. The cache is rebuilt after a ‘jekyll clean’