I need help creating a JavaScript script that can pull images from my Airtable database and automatically upload them to WordPress media folder. The goal is to populate empty image fields across different post types in WordPress.
For instance, if I have a user profile for “John Smith” with an empty avatar field, the script should grab the corresponding image from Airtable and fill that field automatically. I’m pretty new to programming and learning as I go, so any guidance would be awesome.
Here’s what I have so far for connecting to Airtable:
You’ll need to handle the WordPress side to complete this workflow. Your Airtable connection looks solid, but you’re missing the media upload piece.
I dealt with something similar last year migrating thousands of user avatars. The key is using WordPress REST API for media uploads. You’ll need to authenticate with WordPress first, then hit the media endpoint.
Here’s what you need to add after fetching from Airtable: