Add the Featured Image Generation UI#146
Conversation
…hat as a dependency
… closely to render the image and set/remove buttons
…thing to use across loads
…en the component loads
… and add that as meta to the image
… an AI label below the image and only show that if the featured image has the AI meta set
…the text in that case
…text using the post ID. Then take that context and generate an image prompt. Finally pass that prompt into our image generation function. Also modify our system instructions a bit
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @prabinjha, @kurtrank. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #146 +/- ##
=============================================
+ Coverage 50.45% 58.71% +8.26%
- Complexity 379 410 +31
=============================================
Files 27 29 +2
Lines 1992 2175 +183
=============================================
+ Hits 1005 1277 +272
+ Misses 987 898 -89
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ic Ability for image generation
…lity with the proper methods to generate a prompt
…keep the amount of content we send to a minimum
@JasonTheAdams Okay, I've updated this PR to take all the above into consideration. There is now a more specific Ability, This Ability will then generate an image generation prompt which we then pass directly to an image generation model. In my testing this is all working as expected but definitely open to suggestions on the system instructions we're using here and any other default instructions we may want in place to guide things. |
|
@jeffpaul This is ready for final review, noting I've not had success getting this to fully work in the Playground as the request to generate an image typically takes about 60 seconds and Playground always times out before that |
|
This tested really nicely, and yes a bit of a lag in generating but there's :alot: happening in the background. To that specific extent, not something to hold up this PR, but perhaps helpful for a future iteration (but feel free to tell me I'm dumb here and we can skip it) would be some simple "loading text" that describes what's happening (e.g. "Generating image generation prompt from post content...", "Generating image from generated prompt...") so folks understand why its not an immediate response? One thing that I think is worth pausing on to decide how best to land this experiment is the specific alternative text, title, caption, description for generated images. Currently the Title is set as
Perhaps an iteration here to the Alt Text getting generated as well from the resulting image (perhaps hooking into the alt text ability?), the Title getting a truncated or condensed version of the generated alt text, the Caption stays empty as that's meta that more often is also rendered on the front end and may be best left for author/editor input, and the Description gets some provenance info (though anyone who knows me knows I'd LOVE to see something like c2pa-js used to store meta here) so something like “Generated by ExampleAI Image Model v2 on 05 Feb 2026. Prompt: ‘Minimal illustration of a 1700s sailor staring out to see from a dock.’”? |
The only issue here is while yes, we are running lots of things one after the other, they all run fairly quickly besides the actual image generation. So we could add a progress message but I think what we'd see is the message shows then is replaced before someone can actually read it, which may be more annoying then helpful. But the actual image generation part will take time (OpenAI is usually around 60 seconds, Google is typically faster but still ~40 seconds) so maybe still useful to have those messages?
I'm open to any suggestions here, I purposely left it fairly basic as a starting point.
My one concern in regards to alt text is that's a separate Experiment and we can't assume users will have both of those active (Image Generation and Alt Text Generation). In that situation, not sure how we handle that, as the Alt Text Generation Ability won't be available to use if it's not turned on. I guess we could have a light-weight duplicate of that specific to Image Generation, though I could see some complaints there from users wondering why AI is generating alt text when they don't have that Experiment turned on.
Yeah, I agree on keeping this empty
Main issue here is the Ability that generates an image only returns the generated image, it doesn't return anything else, like provider, model, prompt used, etc. We could look to update the Ability to do that if we think that would be valuable, though I'd also need to figure out if the AI Client can tell us what provider and model was used (I'm assuming so but not something I've tried). |
Ok, yeah maybe we ignore this for now and see if there's community feedback about the time to completion and if some sort of loading info is helpful.
Perhaps if the alt text experiment is disabled / that ability is not available, we fall back to adding in directly the raw image gen prompt (knowing that'll likely include sub-optmial "Generate image of" sort of context, but at least someone generating the image could immediately edit/remove it?).
Let's chat about how quickly feasible this could be, balancing that with still getting this feature shipped since its otherwise near ready. |

What?
Partially closes #13. This only handles generating featured images, I'm assuming we'll want image generation in other places as well (though could be tracked in new Issues if we want).
Adds in the UI to trigger Featured Image Generation
Why?
This builds on top of the work done in #134, which added Abilities that could be used to generate an image and/or import an image. This PR adds in the actual UI that triggers those Abilities in the Featured Image section of the edit post screen as well as a new Ability to generate an image generation prompt.
How?
Generate featured imagebutton that shows above the standardSet featured imagebuttonget-post-detailsAbility. Then pass those details to the newimage-prompt-generationAbility, along with our content and context. Take the prompt this generates and pass it to our existingimage-generationAbility. Finally take the base64-encoded image it returns and pass it to our existingimage-importAbility to import the image into the Media LibraryGenerate featured imagetoGenerate new featured imageTesting Instructions
Settings > AI CredentialsSettings > AI ExperimentsGenerate featured imagebuttonTo directly test the new generate image prompt Ability, can make an API requests like the following:
Screenshots or screencast
Test using WordPress Playground
The changes in this pull request can be previewed and tested using this WordPress Playground instance:
Click here to test this pull request.