Add ability to edit existing images in the media library#305
Add ability to edit existing images in the media library#305dkotter wants to merge 23 commits intoWordPress:developfrom
Conversation
…sn't a hook to add this
… as well as a prompt area for specific edits. Set this up to match the flow we use in our image generation components. Add necessary CSS and a helper function to turn an image URL into a base64 encoded image
…n. Some minor style tweaks
…n flow. This allows you to refine an image multiple times, refining the new refined image each time. Ensure we keep track of all prompts used to store with the image. Update text to match our other image generation flows
…wn. Ensure we don't add extra spacing when our tools are hidden
…n to remove a certain color and replace with transparency that we can try out if we want transparent background instead of white background
…he requested image and then sending that along, so the LLM has known boundaries to expand to. Update our remove background prompt to work better with modern LLMs
…t happens, allowing users to paginate back and forth to those images, allowing them to import previously generated images or go back and start the refinment process from a different state
…responses we'll need to test
…til the new Google Provider is released
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #305 +/- ##
==========================================
Coverage 57.43% 57.43%
Complexity 596 596
==========================================
Files 42 42
Lines 3101 3101
==========================================
Hits 1781 1781
Misses 1320 1320
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:
|
|
For some reason my Google credentials aren't working, so I can't fully test this (will continue to see what's going on there so I can test more fully, but have some thoughts for now). I would advocate for just removing the Given that the prompt textarea and Also for the Expand and Remove and Refine buttons let's ensure the base image is still present, as for now clicking AI Edit replaces the image and renders buttons but would be ideal to keep the image and add in the buttons. |
…. Hide the prompt textarea and add a new Refine Image button that when clicked will show that. Minor text and style updates
This is done now. Removed the
Added a For now I haven't added the textarea below the image as it's pretty common for an image to be larger than the screen height and so you'd have to scroll down to see those options. So easy to miss those were added in that scenario. Personally I think this conversational image editing is the most useful thing here (comparing to removing background or expanding the image). My make sense to have that be the first button, at the moment I've left that as the last.
I've left the original image while generation is in place. Once the image is generated, the original image hides as we show that side-by-side with the generated image. |
Oh, didn't realize that was core default, huh ok then I guess ignore me and go back to YELLING AT PEOPLE?
Ok, that makes sense, I concur.
Totally fine moving that to be the first button. |
|
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. |
|
Once you get into a Refine, Expand, or Remove button flow the button options tend to disappear. It would be good to ensure those options are present as image iterations are created. |
Would you expect those buttons to stay where they are at (above the image, below the default buttons)? Or should those show with the other buttons (Save, Refine, Generate, Start over) we render in that preview state, below the images? Pros and cons to both in my mind. I like keeping them where they are at in all states (so above the image) but does also make sense to have them with the other buttons we render, noting we already have 4 buttons in that row so adding 2 more does get overwhelming |
|
If we go with the top, we're effectively duplicating the Refine option in both places. So perhaps in this flow we keep all three buttons at the top and remove the second Refine one from below the image? |



What?
Closes #236, #237
Adds the ability to edit existing images in the media library views.
Why?
We already have the ability to generate images and we're adding the ability to refine those images in #292 but we don't have a way to refine/edit existing images. This PR adds that in via a prompt approach and with a few preset options (
Remove background,Expand background).How?
Remove background,Expand background, andRefine Image, which will add a prompt textarea when clicked that allows you to make conversational edits to the imageUse of AI Tools
Used both Claude Code (running Opus 4.6) and Cursor (running GPT-5.3 Codex) to plan and execute, with final refinement and clean up done by me.
Testing Instructions
npm install && npm run buildEdit ImagebuttonRefine ImageGenerateEdit imageScreenshots