Gemini AI Alt Text Generator

Altvision AI Text Generator - GetSocialGuide – Start Grow & Monetize Your WordPress Blog with Social Media

AltVision AI Text Generator

Generate concise, SEO-friendly alt text for images using Google’s Gemini model — one image at a time. Simple setup, live progress, and built for WordPress.

Altvision AI Text Generator - GetSocialGuide – Start Grow & Monetize Your WordPress Blog with Social Media

   

Download

What this plugin does?

Auto Alt Text Generator inspects images in your Media Library that are missing alt text and uses Google Gemini (single-image endpoint) to generate a short, accurate alt attribute suitable for accessibility and SEO.

Key features

  • Generates human-style alt text (≤125 characters) per image.
  • Uses Gemini 2.5 Flash (single-image generateContent endpoint).
  • Admin UI with progress feedback and results list.
  • Error handling and informative messages for missing files or blocked requests.
  • Safe for bulk work: processes images sequentially (no batch JSON errors).

Why use it?

Good alt text improves accessibility for screen-reader users and gives search engines contextual clues about images. This plugin saves time by producing consistent, concise alt text for images you already uploaded.

Quick install

  1. Download the plugin ZIP and upload it via Plugins → Add New → Upload Plugin in WordPress, or install it directly to wp-content/plugins/.
  2. Activate the plugin through the Plugins screen.
  3. Open the plugin page: Auto Alt Text from the admin menu.
Important: The plugin expects a numeric-only version string in the header (example: Version: 2.2) and different URLs for Plugin URI and Author URI if you plan to publish to the WordPress directory.

Set your Gemini API key

Get your key from Google AI Studio: https://aistudio.google.com/app/apikey.

Enter the API key on the plugin settings page (or leave it in the plugin file while testing). The plugin sends a single-image request to: https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent

How to use

  1. Open Auto Alt Text in the WordPress admin (left menu).
  2. Click Generate Alt Texts. The plugin looks for images with empty alt fields and processes them one by one.
  3. Watch the progress bar and the results area: each processed file will show success or an error message.
  4. Generated alt text is saved into the image’s Alt Text (attachment excerpt / _wp_attachment_image_alt).

Developer note

The plugin uses the single-image generateContent endpoint to avoid JSON batch format errors that happen when trying to send many images in one request. This approach is more compatible with servers that can’t easily assemble large batch payloads or with APIs that expect one `contents` object per call.

Sample request payload

This is the payload structure the plugin sends for a single image request (image data is base64-encoded):

{
  "contents":[
    {
      "parts":[
        { "text": "Write a short and clear alt text (max 125 characters) for this image..." },
        {
          "inline_data": {
            "mime_type": "image/jpeg",
            "data": "BASE64_IMAGE_DATA"
          }
        }
      ]
    }
  ],
  "generationConfig": {
    "temperature": 0.4,
    "maxOutputTokens": 60
  }
}

Response parsing looks for candidates[0].content.parts[0].text to extract the generated alt text.

Troubleshooting

Common errors and fixes

  • HTTP 400 Unknown name “requests” — happens when sending a batch payload to an endpoint that expects a single request. Fix: use the single-image endpoint or the proper batch root endpoint. This plugin uses the single-image endpoint to avoid that issue.
  • Plugin header/version errors — WP requires the Version header to contain only digits and periods (for example 2.2). Remove any extra text like “-beta” or “(test)”.
  • Plugin URI and Author URI must differ — if you publish to the WP directory, make sure Plugin URI and Author URI are not exactly the same URL. You may remove one of them if you don’t have a separate plugin page.
  • cURL or remote post errors — ensure your host supports outbound HTTPS requests; enable cURL or allow wp_remote_post. Check server logs for timeouts or TLS issues.
  • Missing file or permission error — verify the image file exists on disk and that PHP can read it (correct file path and permissions).

Debug tips

  • Enable WP_DEBUG in wp-config.php and check wp-content/debug.log for plugin errors.
  • Log API responses with error_log() or temporarily store responses to a local file for inspection.
  • Test one image first (small file) to confirm the API call and parsing logic work before processing many files.

FAQ

Is generated alt text safe to publish?

Yes — the plugin prompts the model to return concise descriptive text only. Still, always review output for accuracy if images are sensitive or branded.

Can I process hundreds of images?

Yes — but the plugin processes images sequentially (one API call per image). For large libraries you may want to add rate-limit handling, retries, or process in smaller manual batches to avoid hitting API quotas.

Where does the API key go?

You set the key on the plugin settings page or temporarily place it in the plugin file during testing. Recommended: store it in the plugin settings so non-developers can manage it.

Changelog (high level)

  • 2.2 — Clean single-image endpoint migration, header fixes for WP version rules, UI improvements.
  • 1.7 — Batch API attempt (caused JSON payload errors); switched back for stability.
  • 1.6 → 1.5 — General tweaks, progress feedback, better error messages.

Download