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 48.99% 56.76% +7.77%
- Complexity 473 505 +32
=============================================
Files 30 32 +2
Lines 2329 2565 +236
=============================================
+ Hits 1141 1456 +315
+ Misses 1188 1109 -79
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:
|
|
@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). |
…rated image data but also the provider and model metadata
…d provider name. Ensure we are passing those correctly after generating an image
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. |
…e reused when needed
…age, send it off to AI to generate alt text. Otherwise just use the prompt as alt text
…t the image title to be a trimmed version of the alt text
I went ahead and added this as it was pretty simple and now that we're potentially generating alt text as well, that's another few seconds of waiting. So now each step will show a progress message.
Made this change now. If the alt text Experiment is on, after an image is generated we send it back to generate alt text and use that. If that Experiment isn't on, we use the prompt instead. We then take that and trim it down to use as the title instead of hardcoding to
This was also fairly easy so I've gone ahead and made this change. The image generation Ability will now return the image data plus information about the provider and model used. This information is then used in the image description after is is imported. |
|
@adamziel one thing I've run into in using the Playground testing link in this PR is that sometimes Playground stalls out / response times drag on and I'm not reasonably able to test PRs in Playground (with this PR its because of the comms/wait in generating a prompt+image). Perhaps an enhancement for the Playground PR button action would be to also export below the button something like |
Currently getting timeout issues in testing locally, going to build a new local and try again |
|
Ok, got things working locally, phew, one tweak is the date in the Description field is likely US-centric MM/DD/YYYY (I'm guessing) so let's update to DD Month YYYY (e.g. 6 February 2026)? |
Right now we're using
So instead of forcing a particular format, the format used will depend on the individual user's locale and timezone settings. I can update that though if we want to force a specific format for all users. |
While I'd like to make the format a bit more ISO-specific, its probably best to follow the site-specific setting for now and we can always iterate in the future if feedback comes back strongly in a different direction. |

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. If the alt text generation Experiment is turned on, we then pass the image to thealt-text-generationAbility to get accurate alt text (if not enabled, default to using the prompt). 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