---
url: 'http://workflows-of-ai.com/blog/stock-image-finder'
title: 'Stock Image Finder'
author:
  name: 'Marcus Johansson'
  url: 'http://workflows-of-ai.com/about/marcus-johansson'
date: '2023-10-12T14:34:40+02:00'
updated: '2026-10-10T12:14:04+02:00'
type: article
summary: 'Chain two AI Interpolator fields in Drupal: OpenAI writes a stock photo search word, then Pixabay fills the header image.'
tags:
  - 'Marcus Johansson'
  - Workflows
  - 'Drupal AI'
image: 'http://workflows-of-ai.com/sites/default/files/previews/dcae0876d1c9a1d6.jpg'
published: true
og:
  site_name: 'Workflows of AI'
  'image:width': '1280'
  'image:height': '720'
  'image:alt': 'Stock Image Finder'
---
Drupal AI

# Stock Image Finder

Let OpenAI pick a search word from your article and fetch a matching royalty-free header image from Pixabay.

  Marcus Johansson

October 12, 2023 · 2 min read

 ## About this video

In this workflow, the synergy between the AI Interpolator OpenAI and Pixabay modules demonstrates a seamless process of transforming textual content into corresponding visual imagery, enhancing the user experience and content engagement. The entire process is automated, efficient, and tailored to ensure that the images sourced are highly relevant to the article’s content.

Initially, the AI Interpolator OpenAI module is deployed. An article is inputted, and the module’s sophisticated algorithms, powered by OpenAI, meticulously analyze the content. The algorithms are adept at extracting the core themes, topics, and keywords from the text, ensuring a comprehensive understanding of the article’s subject matter. From this analysis, a key search word or phrase that encapsulates the essence of the article is generated. This keyword is not just a random extraction but is derived from a thorough evaluation of the text, ensuring that it is representative of the article’s main theme.

With the search word at hand, the workflow transitions to the AI Interpolator Pixabay module. This module is designed to take the generated search word and utilize it to source relevant images from Pixabay’s extensive library. It inputs the search word into Pixabay’s search engine, initiating a query that sifts through thousands of images to find the one that aligns with the article’s content. The result is a selection of high-quality, relevant images that users can choose from to accompany the article, enhancing visual appeal and engagement. This streamlined process exemplifies the seamless integration and functionality when the AI Interpolator OpenAI and Pixabay modules are employed in tandem.

*This video is from before the AI Interpolator module became AI Automators, part of the [AI module](https://www.drupal.org/project/ai). Module and menu names have changed since, and some steps look different today.*

## Watch the video

[Watch on YouTube: Stock Image Finder](https://www.youtube.com/watch?v=LjgA5WfuIAo)

### Video chapters

- 0:00 Header images from stock photos
- 1:16 The article and Pixabay
- 2:04 Generating a search word
- 3:39 The Pixabay image field
- 4:42 Running the chain

## Transcript

YouTube's automatic captions, lightly corrected. Click a line to jump to that moment in the video.

### Transcript

- 0:01 hey there Marcus here uh in this video I'm going to talk about uh the Pixabay module uh in combination with the OpenAI module and how we can generate uh basically from this article or there's
- 0:18 basically some tourist information I asked uh ChatGPT to create for me about perie uh and say now that we want to autogenerate an header image from stock photos for this this is
- 0:34 basically what we're going to do and we're going to uh use chaining for this meaning that we actually need to do this in two steps um so this is Drupal if you don't know
- 0:47 Drupal since before or the AI Interpolator module in the description of the video there's going to be links there's also links that explains uh what the in AI Interpolator
- 1:00 module isn't um the reasoning why I built it basically or why we built it in our company um everything is open source after you looked at this video you can download it and just replicate it so
- 1:16 let's get started we start with login in uh so we have a content type now called article where we have the actual text then now what we basically want to do is to search on
- 1:33 Pixabay so Pixabay I can show you here is uh uh stock image database that's actually royaltyfree so you're allowed to use this so I could of course go in here search for an image take that and upload
- 1:51 that to an image field and so on um but we want to automate this because maybe we have for some reason we have thousand articles and we want to automate this could be a could be a reasoning behind
- 2:03 this right so where we start is that we want to create a text plane field so just a short field where we want to create a search word based on the article we call
- 2:16 this image search word just one we don't need many we enable the AI Interpolator we're going to use the OpenAI string so it takes any text and users are prompt to rewrite this so
- 2:32 based on the article So based on the context please write one or two words that can be used in a stock photo database be used as search words in a stock photo database use simple words
- 3:00 so basically shouldn't use very complex words because the Pixabay search is not based on AI so it can't recognize complex words it just searches on the words that whoever took theault to put
- 3:13 in right context we open the placeholders and this is going to be the context then uh we just take the rwex we don't care about HTML and so on uh we can put it in batch so we see the
- 3:30 progress we put GPT 4 as well we don't have to set a role in this case we can have moderation on um but in this uh case we need to create another step of course so we need to
- 3:44 have a image field so an image field where we actually put the header image we call it in this case because we want this image to show up on our website as the main image for this article right uh
- 3:58 we just want one image we're not going to set up anything special there we disable the alt field for now and here we enable the AI Interpolator uh so the rule we're going
- 4:11 to use in here is Pixabay image fature we want to generate one image right and we want to base that on the image search word and here comes the next important step then we're going to
- 4:23 use the batch it's very important that we set a a higher weight than the weight of search word getting created because of course the search word has to exist before the actual uh image search
- 4:36 happens otherwise there's going to be like a race condition in our AI chain so and that's it so now we're going to go um I will mention you will see this in the form and you will see it
- 4:50 in the view of the article so if you're actually setting up a CMS you should of course hide the search word the image search words makes no sense in this case in theory I could also fill out the
- 5:02 search Word manually here and it would use that search word to fill the header image then but anyway we save and we have the progress bar that will have two steps in this case because first we're
- 5:14 creating the search word and then we're using the API service to use the search word to download the image then so we have a picture outside the Lo uh and it used a very simple image search for per
- 5:31 right um and yeah that's it basically it's not more complex than this you can automate uh fing your header images using this um so y thanks for watching

  Filed under [Workflows](/blog?category=6) [Drupal AI](/blog?category=2)

Parts of this content were produced by AI.

This site has not assessed whether a label is required for this content.

  How was AI used?The video and the introduction are Marcus's own, first published on workflows-of-ai.com. AI wrote the subtitle, the summary and the video chapters from the transcript, and corrected misheard names in YouTube's automatic captions.

   Marcus Johansson

Tinkers with AI and Drupal

 [About Marcus](/about/marcus-johansson)[Drupal.org profile](https://www.drupal.org/u/marcus_johansson)[Drupal AI](https://www.drupal.org/project/ai)

## The post in three sentences

An OpenAI string field reads the article and writes one or two simple search words for a stock photo database. A header image field then uses the Pixabay image rule with that word, with a higher weight so it runs second. Saving the article runs both steps and attaches a royalty-free image.