I need help building a JavaScript script that fetches images from my Airtable database and uploads them to WordPress media library. The goal is to automatically 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 set it as the profile picture in WordPress.
I’m a beginner programmer learning as I go, so any guidance on the approach would be appreciated. Here’s what I have so far for connecting to Airtable:
u’ll need to use the WordPress REST API along with your Airtable script. First, get the image URL from Airtable, download it as a blob, then upload it to /wp-json/wp/v2/media with the appropriate auth headers. Make sure to use multipart/form-data and include your WordPress auth token!