DALL-E & Craft - A Little Side Project

Posted: 10th Nov 2022

Reducing the barriers for content editors is a key part of what makes Craft an attractive CMS. We know that first hand, handling a couple of blogs for Servd and other sites.

But one aspect of content writing that we've always found a chore is the sourcing and editing of stock photography to use as a piece's hero image. And we all know that content without a hero image will tank those social media clicks.

Wouldn't it be nice if we could not just source stock images from inside Craft, but actually generate the exact image that we're after?

This past week we wanted to get reacquainted with some of Craft's internals, and it just so happened that Open AI's DALL-E API went into public beta! All of the stars aligned for us to try to solve the hero image problem once and for all.

The result is DALL-E Fieldtype for Craft, a Craft CMS plugin which brings DALL-E text-to-image generation directly into the Craft Control Panel.

It has been designed to work seamlessly with your existing Craft content model - simply replace your existing 'Assets' fields with 'Assets with DALL-E' fields. The fields work in exactly the same way as regular Asset fields, allowing you to select existing assets or upload new ones, but adds an additional button to 'generate' an image to use.

Content editors can generate multiple images from a text prompt, choose which they prefer, generate similar variants of an image and even extend the image horizontally to form a landscape version - all managed from within a modal so it doesn't ruin your nicely curated content modelling UI.

We've also included a form of art direction by allowing specific fields to have a standardized prompt prefix and suffix, allowing you to ensure all images generated share a common theme. We use 'a detailed pencil sketch of' for our hero images in this blog.

The plugin is available in the Craft Plugin Store. If you'd like to give it a go you'll need to sign up for Open AI API access which you can do here. During the beta period they're giving $18 testing credit to everyone who signs up. Each image generated by DALL-E costs $0.02 so there's plenty of opportunity to give it a go and see if it helps with your workflow!

We have some setup and additional plugin information in the plugin's README here.

The hero image for this blog post was created using this plugin - it's unlikely we'd have found 'a detailed pencil sketch of a robot holding a paintbrush in front of an easel' anywhere else...