Skip to content

AI Alt Text

Generate alt text for images using AI. Supports multiple AI providers including OpenAI, Claude, Gemini, Ollama, Azure OpenAI, and Grok.

AI Alt Text Plugin Screenshot
  • Bulk Update: Update alt text for multiple images at once from the media library
  • Block Editor Integration: Generate alt text directly from the image block in the editor
  • Multiple AI Providers: Choose from OpenAI (GPT-4o), Anthropic Claude, Google Gemini, Azure OpenAI, Ollama (local), or Grok
  • Language Detection: Automatically uses WordPress language settings for generated alt text
  • Flexible Configuration: Configure via constants, environment variables, or the admin settings page
  • WordPress 6.8 or higher
  • PHP 8.3 or higher
  • API key for your chosen AI provider (except Ollama which runs locally)
  • Quick Install

    • Download ai-alt-text.zip
    • Upload via Plugins > Add New > Upload Plugin
    • Activate the plugin.
    • Go to Settings → AI Alt Text to configure your AI provider
  • Composer Install

    Terminal window
    composer require soderlind/ai-alt-text
  • Updates

Navigate to Settings → AI Alt Text and configure:

  1. Select your AI provider
  2. Enter your API key
  3. Optionally customize the model and other settings
// AI Provider: 'openai', 'anthropic', 'gemini', 'azure', 'ollama', 'grok'
define( 'AI_ALT_TEXT_PROVIDER', 'openai' );
// API Key
define( 'AI_ALT_TEXT_API_KEY', 'your-api-key-here' );
// Optional: Custom model
define( 'AI_ALT_TEXT_MODEL', 'gpt-4o' );
// Azure-specific settings
define( 'AI_ALT_TEXT_AZURE_ENDPOINT', 'https://your-resource.openai.azure.com' );
define( 'AI_ALT_TEXT_AZURE_DEPLOYMENT', 'your-deployment-name' );
// Ollama-specific settings
define( 'AI_ALT_TEXT_OLLAMA_HOST', 'http://localhost:11434' );
Terminal window
AI_ALT_TEXT_PROVIDER=openai
AI_ALT_TEXT_API_KEY=your-api-key-here
AI_ALT_TEXT_MODEL=gpt-4o
  1. Go to Media → Library (list view)
  2. Select images you want to update
  3. Choose “Generate AI Alt Text” from the bulk actions dropdown
  4. Click “Apply”
  1. Add or select an image block
  2. In the sidebar, find the “AI Alt Text” panel
  3. Click “Generate Alt Text with AI”
ProviderModelNotes
OpenAIgpt-4oRequires API key from OpenAI
Anthropicclaude-sonnet-4-20250514Requires API key from Anthropic
Google Geminigemini-2.0-flashRequires API key from Google AI Studio
Azure OpenAIgpt-4oRequires Azure subscription and deployment
OllamallavaFree, runs locally. Install from ollama.ai
Grokgrok-2-vision-1212Requires API key from xAI

For detailed configuration instructions, see AI Provider Documentation.

add_filter( 'ai_alt_text_generated', function( $alt_text, $attachment_id ) {
// Modify the generated alt text
return $alt_text;
}, 10, 2 );
add_filter( 'ai_alt_text_prompt', function( $prompt, $language ) {
// Customize the prompt sent to the AI
return $prompt;
}, 10, 2 );
add_filter( 'ai_alt_text_should_generate', function( $should_generate, $attachment_id ) {
// Return false to skip auto-generation
return $should_generate;
}, 10, 2 );

The plugin is translation-ready. Translation files are located in the languages/ directory.

  1. Copy languages/ai-alt-text.pot to languages/ai-alt-text-{locale}.po
    • Example: ai-alt-text-nb_NO.po for Norwegian Bokmål
    • Example: ai-alt-text-de_DE.po for German
  2. Translate the strings using Poedit or similar tool
  3. Save to generate the .mo file
  4. For JavaScript translations, run:
    Terminal window
    wp i18n make-json languages/

Contributions welcome! Submit your translation via a pull request.

Terminal window
npm install
npm run build
Terminal window
# JavaScript tests
npm test
# PHP tests
./vendor/bin/phpunit
Terminal window
# Check PHP code standards
./vendor/bin/phpcs
# Fix PHP code standards
./vendor/bin/phpcbf

GPL v2 or later. See LICENSE for details.

Developed by Per Soderlind.