All guides

Generate AI alt text for your WordPress media library: a plugin you can build today

· 4 min read

WordPress does not generate alt text when you upload an image. You either write it by hand or leave the field empty, and most people leave it empty. A travel photographer who uploads fifty photos from a weekend trip does not want to write fifty captions before publishing. A shop owner adding product photos one by one does the same. Over months, a media library fills with images that are invisible to search engines and unreadable to screen readers.

AI image description has become cheap enough that a single API call costs a fraction of a cent. Plugins exist that do this automatically, but the free tiers are meagre, typically twenty images per day and one at a time. If you have your own OpenAI API key, the limit is gone. A custom plugin sends each image URL to the Vision API, gets a short description back, and writes it to the standard WordPress alt text field. That is all it does, and it is a few minutes to set up.

What one build gives you

  • Bulk-generate alt text for all images in the media library that have none
  • Single-image generation from the attachment edit screen
  • Admin settings for API key, model choice, and the skip rule for existing alt text
  • Output stored in the standard WordPress alt text field, compatible with all themes and SEO plugins

What it does not do

  • Automatic alt text generation on image upload
  • Alt text for PDFs, audio files, or video attachments
  • Translation of generated alt text into multiple languages
  • Rewriting or improving alt text that already exists

Alt Text AI does these. This covers the part most sites use.

The prompt

Loads into the composer so you can edit it first. Nothing is built, and nothing is charged, until you send it.

Build a WordPress plugin that generates alt text for media library images using the OpenAI Vision API. Add a settings page under Settings > AI Alt Text with three fields: an OpenAI API key, a model selector with options gpt-4o-mini and gpt-4o, and a checkbox labelled Skip images that already have alt text (checked by default). Add an admin page called AI Alt Text under the Media menu that shows a table of all image attachments with columns for thumbnail, filename, current alt text (shown as a dash if empty), and a Generate button per row. Include a Bulk Generate button at the top that processes all images matching the skip rule via AJAX with a progress bar. When generating for an image, send the attachment URL to the OpenAI Chat Completions API using a user message with an image_url content part and a text prompt asking for concise descriptive alt text under 125 characters suitable for screen readers, then save the response to the _wp_attachment_image_alt post meta field. On the individual attachment edit screen in wp-admin, add a Generate AI Alt Text button below the alt text field that triggers the same process for that single image via AJAX.

Build this pluginAbout 55 credits · the free plan includes enough for one

Why missing alt text compounds over time

Search engines cannot see images. They index the alt text field, the filename, and the surrounding copy. A library of images with names like DSC_4829.jpg and empty alt text contributes nothing to image search and weakens the relevance signals for every page those images appear on.

Screen readers read the alt text field aloud to visually impaired visitors. A photo with no alt text is announced as a blank or skipped entirely. WordPress has no bulk alt text editor. The only way to fix a large backlog is to open each attachment individually, type a description, and save. That is the job this plugin replaces.

Why the per-day limit frustrates people

Most AI alt text tools for WordPress connect to the vendor's API rather than OpenAI directly. That middle layer lets the vendor control costs, which is why free tiers top out at around twenty images per day. For a site with five hundred photos, that is more than three weeks of waiting.

If you have your own OpenAI API key, the intermediary is unnecessary. The plugin reads the image URL, sends it to OpenAI's Vision API, and writes the response to the database. There is no account to create, no daily reset to wait for, and no data passing through a third-party service.

What the plugin delivers

A Steem build for this job adds an AI Alt Text page under the Media menu and a settings page under Settings where you enter your OpenAI API key and choose a model. gpt-4o-mini handles this job well and costs less per call than gpt-4o; the prompt is short and the output is a single sentence.

How to install and use it

Paste the prompt below into Steem and the plugin builds as a downloadable zip. Install it under Plugins > Add New > Upload, then go to Settings > AI Alt Text and enter your API key.

Open Media > AI Alt Text. Click Bulk Generate to fill all images without alt text. The plugin sends each image URL to OpenAI in sequence, receives a short description, and writes it to the database. A library of several hundred images takes a few minutes to process.

When to use a managed service instead

If you need alt text generated automatically on every new upload, a managed service is the simpler option. Some handle the upload hook out of the box. Adding it to a custom build is a second prompt, but it requires one.

If you manage multiple sites, want brand-specific language in your descriptions, or need alt text in multiple languages, a platform with centralised configuration handles that better than a per-site plugin. For a single site with a backlog of untagged images, a custom build with your own key is the cheaper and faster path.

Questions

What does each API call cost?
gpt-4o-mini is one of OpenAI's cheapest vision models. A typical image description request costs a fraction of a cent. A library of 500 images will cost a few dollars at most, and you only pay when you generate or regenerate, not on every page load.
Will it work on images already in my media library, or only new uploads?
It works on images already uploaded. The plugin reads each attachment URL and sends it to OpenAI. There is no need to re-upload anything.
Does it work with WooCommerce product images?
Yes. WooCommerce product images are standard WordPress attachments stored in the media library, so they appear in the plugin's table and are included in bulk generation.
Can I overwrite alt text that I wrote manually?
By default the plugin skips images that already have alt text. To overwrite everything, uncheck the skip setting before running bulk generation.

The prompt

Loads into the composer so you can edit it first. Nothing is built, and nothing is charged, until you send it.

Build a WordPress plugin that generates alt text for media library images using the OpenAI Vision API. Add a settings page under Settings > AI Alt Text with three fields: an OpenAI API key, a model selector with options gpt-4o-mini and gpt-4o, and a checkbox labelled Skip images that already have alt text (checked by default). Add an admin page called AI Alt Text under the Media menu that shows a table of all image attachments with columns for thumbnail, filename, current alt text (shown as a dash if empty), and a Generate button per row. Include a Bulk Generate button at the top that processes all images matching the skip rule via AJAX with a progress bar. When generating for an image, send the attachment URL to the OpenAI Chat Completions API using a user message with an image_url content part and a text prompt asking for concise descriptive alt text under 125 characters suitable for screen readers, then save the response to the _wp_attachment_image_alt post meta field. On the individual attachment edit screen in wp-admin, add a Generate AI Alt Text button below the alt text field that triggers the same process for that single image via AJAX.

Build this pluginAbout 55 credits · the free plan includes enough for one

Read next

Other plugins you can build this way

Each loads into the composer, ready to edit.