Search by

heavymetalavo / craft-aialttext

heavymetalavo

Generate suitable alt text for CraftCMS Asset Images

Package info

github.com/heavymetalavo/craft-aialttext

Documentation

Type:craft-plugin

pkg:composer/heavymetalavo/craft-aialttext

Statistics

Installs: 1 586

Dependents: 0

Suggesters: 0

Stars: 5

Open Issues: 16


README

README · Getting started · AI providers · Settings · Console commands · Images · Costs

AI Alt Text, for Anthropic, OpenAI, Langdock and OpenRouter, on Craft 5 and Craft 4 (lite). A photo of a polar bear waving, with its alt text below: "A young polar bear standing upright on snow, raising one paw as if waving, with a grey sky behind it."

Write alt text for every image on your Craft site with AI: one click, in bulk, or as images are uploaded, in each site's language.

🚨 New in 5.3: OpenRouter support, with hundreds of vision models behind one API key.
🚨 New in 5.2: Langdock support, for Claude and GPT models hosted in the EU.

Plugin Store | GitHub Repository

✨ What you get

  • Any vision model, one key. Use Anthropic or OpenAI directly, Langdock (hosted in the EU), or OpenRouter, which offers over 300 image-capable models, including Claude, GPT, Gemini, Grok, Qwen and DeepSeek. Switching model is one setting. OpenAI and Anthropic models are supported, and more than 50 others worked in our tests. See AI providers.
  • Pennies for a whole library. With our top pick, claude-haiku-5-5, alt text for 1,000 images costs about 23 cents, or about 6 cents with gpt-6-luna. Compare models.
  • Every site's language. Alt text is written in the site's language, and can be saved to each site of a multi-site install.
  • One click, in bulk, or automatically. From an asset's action menu, for selected assets, from the bulk actions utility, on upload or file replacement, or from the command line. Bulk work runs through Craft's queue, where failed jobs can be retried.
  • Awkward images handled. Large images are scaled to each provider's limits, SVG, AVIF, HEIC and HEIF are converted, animated GIFs use their first frame, and private volumes are sent as base64. See Images.
  • Your prompt, your rules. Edit the instructions sent to the AI, with {asset.*} and {site.*} variables. See Settings.
  • Permissions built in. Bulk generation has its own utility permission, and single assets follow the asset's own save permission.

How it works, in four steps. 1, triggered: on upload or file replacement, from an asset's action menu, for selected assets, from the bulk actions utility or the command line. 2, prepared: SVG, AVIF, HEIC, HEIF and animated GIFs are converted, and large images are scaled to the provider's limits. 3, described: sent with your prompt to a vision model through Anthropic, OpenAI, Langdock or OpenRouter, which writes the alt text in the site's language. 4, saved: written to the asset's native alt field for that site, and to its other sites if you choose.

🎬 Video walkthrough

A full walkthrough of all plugin features - watch on YouTube:

Watch the AI Alt Text plugin walkthrough on YouTube

🚀 Quick start

Craft CMS 5.0.0 or later (running Craft 4? Use the 4.x branch), PHP 8.2 or later, and an API key for Anthropic, OpenAI, Langdock or OpenRouter.

composer require heavymetalavo/craft-aialttext
./craft plugin/install ai-alt-text
  1. Choose a provider and add its API key under Settings → AI Alt Text, see AI providers.
  2. Add the native alt field to your asset volumes' field layouts, see Field requirements.
  3. Generate alt text from an asset's action menu, the bulk actions utility, on upload or from the command line.

Then use it in your templates:

<img src="{{ asset.url }}" alt="{{ asset.alt ?: asset.title }}">

📚 Documentation

  • Getting started - requirements, installation, the alt field, generating alt text, troubleshooting
  • AI providers - API keys for Anthropic, OpenAI, Langdock and OpenRouter, and choosing a model
  • Settings - every setting, the default prompt, image detail, reasoning effort and permissions
  • Console commands - stats, missing, all and single
  • Images - supported file types, scaling and conversion, private volumes and limitations
  • Costs - estimated cost per alt text by model, and avoiding unexpected charges

⚠️ Disclaimer

We've taken some steps to try prevent unexpected costs with default plugin settings (e.g. detail: low and suggested small models such as claude-haiku-5-5) though we take no responsibility for excessive API token usage that may result from mistakes, bugs, or security vulnerabilities within this plugin so use at your own risk. See Avoiding unexpected charges.

🙋 Support

If you encounter any issues or have questions, please submit them on GitHub.

Credits

The eye icon used in this project is from SVG Repo and is available under the CC0 1.0 Universal (Public Domain) license.