Auto-publishing photos from Google Drive to WordPress
The problem
Cross Fire Cooking is Matt Cross's live fire cooking business, running BBQ classes and private catering. Matt has a big following on social, and the website shows off the food in a gallery on the our food page and in the footer of every page.
Getting new photos up meant Matt sending them to us and waiting for us to add them. Fine now and then, but the gallery went stale between batches.
Before that, the site pulled in an Instagram feed. It looked like the easy option, but reposts and collab posts landed on the site too, so Matt lost control of what was shown.
What he wanted was simple: something he could curate himself, that stayed up to date without any effort.
The fix
Matt already uses Google Drive, so that became the upload button. He drops a photo into a shared folder, and within a minute it's live on the site.
Behind the scenes it's one n8n workflow with two branches.
Upload. n8n watches the folder. When a new photo appears, it downloads it and sends it to the WordPress media library through the REST API. Each image is tagged with its Drive file ID, so we can match it up later.
POST /wp-json/wp/v2/media?post={holderPageId}&description=drive:{driveFileId}Cleanup. Google Drive doesn't tell you when a file is deleted. So every 4 minutes, n8n compares what's in the folder with what's on the site, and removes anything that's no longer in Drive.
We added a few safety rails, because an automation that deletes things needs them:
- If Drive returns no files (an expired login, an API hiccup), the run does nothing. Otherwise one glitch could wipe the whole gallery
- If more than 10 images would be deleted in one go, it stops and flags an error
- Images without a Drive tag are never touched
On the site, a small shortcode shows the latest images, 4 across on desktop and 2 by 2 on mobile.
Why not a plugin?
There are plugins that embed a Drive folder straight onto a page, and they're quicker to set up. We passed, because the images are served from Google. That means slower loading, none of the site's own image optimisation, and no SEO benefit. Syncing into the media library means they're proper WordPress images.
Got a similar problem? Let's talk.
Book a call(opens in a new tab)