## Summary Implement WP-CLI command to generate alternative text for image attachments using the WordPress AI Client, following WordPress/ai#44. ## What was added New subcommand under `wp ai generate`: ```bash wp ai generate alt-text <attachment_id> ``` ### Capabilities - Validates attachment exists and is image type - Converts image to data URI for vision model processing - Generates alt text via WordPress AI Client - Enforces 125-character limit (WCAG guideline) - Updates `_wp_attachment_image_alt` post meta - Supports all standard options: `--provider`, `--model`, `--temperature`, `--top-p`, `--top-k`, `--max-tokens`, `--system-instruction` ## Example usage ```bash $ wp ai generate alt-text 123 Success: Alt text generated and saved for attachment 123: A WordPress logo on a blue background ``` ## Implementation - Added `generate_alt_text()` private method to `AI_Command` class - Uses WordPress AI Client `with_file()` builder method for vision input - Error handling: missing attachment, non-image type, unreadable file, unsupported model - Test coverage: added Behat scenarios for error cases ## Related - Upstream: WordPress/ai#44 - Branch: `feat/alt-text-generation`
Activity
swissspidy commentedon Jun 29, 2026
I'm not sure this warrants its own command. Alt text generation is simply generating text while providing an input image.
Could we perhaps just support this in
wp ai generate textand allow providing input image(s)? They could be local, URLs, or attachment IDs.