How to Fetch Wikimedia Commons Images with Make.com (with Attributions)

This guide explores how to efficiently fetch images from Wikimedia Commons and upload them to WordPress using Make.com. I’ll walk you through setting up a workflow that not only uploads images but also handles image attribution seamlessly.

Fetching images from Wikimedia Commons and uploading them to WordPress involves several steps. I created an automation that streamlines this process using Make.com. The automation fetches images based on a specific query, processes the response, and uploads the images along with proper attributions. Understanding each step of this workflow is essential for anyone looking to implement a similar solution.

Setting Up Your Query

To begin, I hard-coded a query variable named “query” with the value “Birds.” This is a simple way to test the setup. In a real-world scenario, you would typically link this query to a dynamic source like an Airtable or Google Sheet. This allows for more flexibility in retrieving different images based on user input or other triggers.

Parsing the Response from Wikimedia Commons

Once the query is established, the next step is to send it to Wikimedia Commons and parse the response. After making the request, I examined the response data. It includes various elements, such as image information and URLs. This data is crucial for the next steps in the automation process.

Filtering Results to Ensure Validity

Before proceeding with uploading the images, it’s important to filter the results. I added a filter to ensure that the automation only continues if valid results exist. This step prevents any errors that might occur if no images are returned from the query.

Integrating OpenAI GPT for Attribution

To ensure proper attribution for the images fetched from Wikimedia Commons, I integrated OpenAI’s GPT model into the automation. This step is essential because the attribution data can come in various formats, making it difficult to standardize. By using GPT, I can transform this data into a consistent format that is easy to use.

The process involves setting up a prompt that instructs GPT to provide the attribution details in a specific JSON format. This format includes the image URL, the file name without the extension, and the license details. I found that this approach not only saves time but also enhances the accuracy of the attribution.

Integrating OpenAI GPT for image attribution

Creating the OpenAI Module

I added an OpenAI module to the workflow. The first step was to select the latest chat model. Then, I crafted a system prompt to guide the AI’s responses. By specifying what I wanted, I ensured that GPT would return the necessary details in a structured format.

This setup allows me to retrieve multiple data items from a single API call, which is efficient and reduces the chances of errors. The AI processes the input data and outputs the required information, including the image credit and license details.

Uploading Images to WordPress

The next phase in the automation is uploading the images to WordPress. I used the HTTP module to fetch the image file using the URL obtained from the previous steps. This process is straightforward, but there are a few considerations to keep in mind.

Firstly, I ensured that the image URL exists before proceeding to the upload. This check prevents unnecessary errors in the workflow. Once confirmed, I mapped the image URL to the upload function in WordPress.

Handling File Names

One of the quirks of the WordPress module in Make.com is that if an image has the same name as an existing file, it will overwrite that file. To avoid this, I modified the file name by appending a timestamp to it. This guarantees that each image uploaded has a unique name, preventing any accidental overwrites.

After setting the file name, I selected the appropriate file extension and proceeded with the upload. The process is seamless, and once the image is uploaded, I can retrieve its publicly accessible URL.

Adding Attributions to Your Blog Post

Once the images are uploaded, I moved on to incorporating the attributions into the blog post. I constructed the HTML necessary to display the image alongside its attribution. This step is crucial for maintaining compliance with copyright laws and ensuring that content is used ethically.

For each image, I added an image tag to the blog content. This tag includes the source URL of the uploaded image. Additionally, I included the attribution text, which I had formatted earlier using GPT. This ensures that readers can easily see who created the image and under what license it is shared.

Formatting Attribution HTML

To format the attribution properly, I inserted a paragraph tag containing the attribution text at the bottom of the blog post. This method not only organizes the content but also keeps it visually appealing. If desired, I can adjust the format to meet specific design requirements.

The final step in this process is to decide whether to include the attribution for the featured image as well. If I choose to do so, I can replicate the process, ensuring that all images used in the post are credited appropriately.

Formatting attribution HTML for blog

With the images uploaded and attributions added, the workflow is complete. I can now run the automation, and it will efficiently fetch images from Wikimedia Commons, upload them to WordPress, and ensure that all necessary attributions are included in the blog post.

Leave a Comment