Add image input support to wp ai generate text#21
Draft
swissspidy with Copilot wants to merge 6 commits into
Draft
Add image input support to wp ai generate text#21swissspidy with Copilot wants to merge 6 commits into
wp ai generate text#21swissspidy with Copilot wants to merge 6 commits into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 Jul 6, 2026
wp ai generate text
There was a problem hiding this comment.
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>towp ai generate text, wiring image input into the prompt builder. - Introduces private helpers in
AI_Commandto 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 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 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." ); | ||
| } |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rather than a dedicated
wp ai generate alt-textsubcommand, image input is surfaced directly inwp ai generate textvia a new--imageoption, keeping vision-based text generation (alt text, image description, etc.) as a natural extension of the existing command.Changes
--image=<image>option added towp ai generate text, accepting:http:///https://) — passed directly towith_file()data:…) — passed directlyimage/, converts to data URIAI_Command:with_image_input(),with_attachment_input(),with_local_file_input()Example