Skip to content

Add image input support to wp ai generate text#21

Draft
swissspidy with Copilot wants to merge 6 commits into
mainfrom
copilot/cli-support-image-alt-text
Draft

Add image input support to wp ai generate text#21
swissspidy with Copilot wants to merge 6 commits into
mainfrom
copilot/cli-support-image-alt-text

Conversation

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Rather than a dedicated wp ai generate alt-text subcommand, image input is surfaced directly in wp ai generate text via a new --image option, keeping vision-based text generation (alt text, image description, etc.) as a natural extension of the existing command.

Changes

  • --image=<image> option added to wp ai generate text, accepting:
    • WordPress attachment ID (numeric) — reads local file → data URI, falls back to attachment URL
    • Remote URL (http:///https://) — passed directly to with_file()
    • Data URI (data:…) — passed directly
    • Local file path — validates MIME type starts with image/, converts to data URI
  • Three private helpers added to AI_Command: with_image_input(), with_attachment_input(), with_local_file_input()
  • Mock provider updated in Behat fixtures to declare image and text+image input modalities
  • Five new Behat scenarios: local PNG success, missing file, non-existent attachment ID, non-image file type, non-attachment post ID

Example

# Describe a local image
wp ai generate text "Describe this image" --image=photo.jpg

# Generate alt text for a media library attachment
wp ai generate text "Generate alt text for this image" --image=42

# Pass a remote image URL
wp ai generate text "What is in this image?" --image=https://example.com/photo.jpg

Copilot AI linked an issue Jul 6, 2026 that may be closed by this pull request
@github-actions github-actions Bot added command:ai-generate Related to 'ai generate' command documentation Improvements or additions to documentation enhancement New feature or request scope:testing Related to testing labels Jul 6, 2026
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.14286% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/AI_Command.php 57.14% 18 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI and others added 3 commits July 6, 2026 12:04
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement CLI support for image alt text generation Add image input support to wp ai generate text Jul 6, 2026
Copilot AI requested a review from swissspidy July 6, 2026 12:08
@swissspidy swissspidy added this to the 1.0.2 milestone Jul 6, 2026
@swissspidy swissspidy requested a review from Copilot July 6, 2026 12:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the existing wp ai generate text command to support vision-style prompts by allowing an image to be supplied via a new --image option, rather than introducing a separate subcommand.

Changes:

  • Adds --image=<image> to wp ai generate text, wiring image input into the prompt builder.
  • Introduces private helpers in AI_Command to accept attachments, URLs/data URIs, and local files.
  • Updates the Behat mock provider metadata and adds Behat scenarios covering image-input success and failure cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/AI_Command.php Adds --image option handling and helper methods to attach image input to text-generation prompts.
features/generate.feature Updates mock provider supported input modalities and adds scenarios validating --image behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/AI_Command.php
Comment on lines +80 to +82
* [--image=<image>]
* : An image to use as input for text generation. Can be a local file path, a URL, or a WordPress attachment ID.
*
Comment thread src/AI_Command.php Outdated
Comment thread src/AI_Command.php
Comment thread src/AI_Command.php
Comment on lines +564 to +568
$attachment = get_post( $attachment_id );

if ( ! $attachment || 'attachment' !== $attachment->post_type ) {
WP_CLI::error( "Attachment with ID {$attachment_id} not found." );
}
Copilot AI and others added 2 commits July 6, 2026 12:25
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:ai-generate Related to 'ai generate' command documentation Improvements or additions to documentation enhancement New feature or request scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI support for image alt text generation

3 participants