feat: Add standalone AI image generation interface to the Media Library.#258
Conversation
|
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 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 #258 +/- ##
=============================================
+ Coverage 57.48% 57.68% +0.20%
- Complexity 563 567 +4
=============================================
Files 35 35
Lines 2907 2933 +26
=============================================
+ Hits 1671 1692 +21
- Misses 1236 1241 +5
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:
|
|
Investigated the failing PHP trunk tests — the fatal error originates in |
Yes, known issue between the version of the AI Client we load and the version that is now merged into |
src/experiments/image-generation/components/GenerateImageStandalone.tsx
Outdated
Show resolved
Hide resolved
src/experiments/image-generation/components/GenerateImageStandalone.tsx
Outdated
Show resolved
Hide resolved
|
Besides some threaded comments above, my primary testing feedback is the post-generation flow. Here is what currently results:
Perhaps we instead send folks back to the Media Library with the generated image present (as they have the
Alternatively, perhaps we send them to the
Or to the
I'm curious if @karmatosed has a particularly strong preference here? |
|
@jeffpaul thanks for looping me in. I think in this case the 'attachment page' works. I typically like things to stay on same screen but it will get lost if we keep it there and that screen doesn't really have a good highlight. I like idea of even adding a 'regenerate' option there but that's another scope creep. |
|
@dkotter @jeffpaul & @karmatosed. I intentionally kept the user on the Generate Image page after saving to allow batch generation without back-and-forth navigation — which felt like the primary use case for someone in the Media Library context vs the block editor, where inserting the image is the end goal. That said, I think the middle ground makes sense: I'll add a "View in Media Library" link alongside the "Generate Another Image" button in the success state. This gives users who want to inspect or edit the attachment a direct path without forcing navigation for those who want to keep generating. |
0e9d62e to
96e9bc0
Compare
…et enqueuing, and improve image upload JSDoc.
…eration` to `ai_image_generation` in image generation tests.
…eration experiment tests.
96e9bc0 to
eb2e195
Compare
…ve image refinement functionality from the standalone component.
eb2e195 to
0fcbe7b
Compare
|
@dkotter @jeffpaul @karmatosed — updated the success state to include two buttons: "Generate Another Image" (keeps the current flow intact for batch generation) and "View in Media Library" which takes the user directly to the attachment details page for the saved image. The attachment details page felt like the right destination over the media grid since the user can immediately review and edit the auto-generated title, alt text and description — which is likely the next thing they'd want to do. WordPress's built-in prev/next navigation in the top-right also lets them browse previously generated images without any additional custom code on our end. Screenshots attached showing the updated success state. Happy to adjust if you'd prefer the link goes to the media grid instead.
|
src/experiments/image-generation/components/GenerateImageStandalone.tsx
Outdated
Show resolved
Hide resolved
…e component to use it.
dkotter
left a comment
There was a problem hiding this comment.
Tested again and things work fine so approving this.
I do think there's some refinement we could make here around the loading state. I'm also seeing some weird shifting after an image is generated and then when you choose to import that or regenerate. Seems the width of the container is changing so the image decreases in size a bit. Not a blocker but something we can look to refine
|
Thanks for testing and the approval, @dkotter! Agreed on both the loading state and the container width shift — I can reproduce the latter too. Would you prefer I address these here before merge, or should we track them as a follow-up issue so this PR can land cleanly? Happy to do either. |
@zeus2611 I'd say so we don't hold this PR up for merge (and getting a release out) we can tackle these in a follow-up PR. I think the layout shift will be easy but may want more conversation around the loading state, trying to figure out what works best both here and when generating images within the editor |
|
Sounds good, @dkotter! That aligns with my thinking too — while working on the last change request I did consider touching the loading state but held back since getting it right across both the inline and standalone contexts felt like something worth discussing as a team rather than deciding unilaterally. I'll open a follow-up issue to track both the layout shift and the loading state so we have a clear place for that conversation. |







What?
Closes #254
Adds a standalone image generation interface accessible from the WordPress Media Library, allowing users to generate AI-powered images outside the block editor.
Why?
#235 introduced image generation within the block editor. This PR extends that functionality into the Media Library so users can generate images independently of the post editor context, as outlined in #254. This opens up the image generation capability to any workflow that involves the Media Library.
How?
Backend (PHP)
Image_Generation.php: Addedregister_admin_menu()to register a "Generate Image" submenu item under Media usingadd_media_page()Image_Generation.php: Addedrender_admin_page()to output the admin page shell with a React mount point (#ai-image-generation-root)Image_Generation.php: Addedinject_generate_image_button()hooked toadmin_footer-upload.phpto inject a "Generate Image" action button into the Media Library header alongside "Add New Media File". Uses a capture-phase click listener to bypass WordPress's media grid JS event delegationImage_Generation.php: Updatedenqueue_assets()to load scripts onupload.phpandmedia_page_ai-image-generationin addition to post editor screensFrontend (React/TypeScript)
GenerateImageStandalone.tsx: New standalone React component providing the full image generation flow:media-library.tsx: MountsGenerateImageStandaloneon the admin page's#ai-image-generation-rootelementindex.ts: Addedimport './media-library'entry pointTemporary Scaffolding
uploadImageLocal()inGenerateImageStandalone.tsxis a local fallback for image upload functionality. Once Inline image generation #235 is merged, this will be replaced with the shareduploadImagefunction from../functions/upload-imageduring rebase.Use of AI Tools
Implementation was planned and executed with assistance from Gemini (Antigravity). All code was reviewed, tested, and validated manually in a local WordPress environment.
Testing Instructions
Settings > AI Credentials(Google or OpenAI support image generation)Settings > AI ExperimentsMedia > Libraryin wp-adminMedia > Generate Imagein the sidebar and verify the same standalone UI loads correctlyTesting Instructions for Keyboard
Screenshots or screencast