mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #20239] [CLOSED] fix: image editing with uploaded images after file storage refactor #48563
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20239
Author: @Classic298
Created: 12/29/2025
Status: ❌ Closed
Base:
dev← Head:image-fix📝 Commits (5)
a0da16dfix: image editing with uploaded images after file storage refactor725d7bdClaude/fix image editing l qq9 n (#138)d186224Claude/fix image editing l qq9 n (#139)ca71b78fix48fda8efix📊 Changes
7 files changed (+63 additions, -18 deletions)
View changed files
📝
backend/open_webui/routers/images.py(+47 -10)📝
backend/open_webui/utils/middleware.py(+5 -1)📝
src/lib/components/chat/Messages/ResponseMessage.svelte(+2 -2)📝
src/lib/components/chat/Messages/UserMessage.svelte(+6 -2)📝
src/lib/components/common/Collapsible.svelte(+1 -1)📝
src/lib/components/notes/NoteEditor.svelte(+1 -1)📝
src/lib/components/notes/NoteEditor/Controls.svelte(+1 -1)📄 Description
Description
This PR fixes image handling issues that broke after the v0.42/v0.43 refactoring which changed how images are stored in chats. Previously, images were stored as base64 data directly in the chat JSON. After the refactor, images are stored as Files in the database and referenced in the chat JSON as URLs (file IDs) for page loading speedup and caching benefits.
This change inadvertently broke:
Root Cause Analysis
Bug 1:
get_images_from_messagesonly checkedtype == "image"Location:
backend/open_webui/utils/middleware.pyThe function extracts images from chat messages to determine whether to trigger image editing vs image generation. It only checked for
file.get("type") == "image".However, when images are uploaded through the file upload API (non-temporary chats), they are stored with:
type: 'file'(not'image')content_type: 'image/png'(or other image MIME type)url: '{file_id}'This caused uploaded images to be completely ignored, resulting in the image generation path being taken instead of image editing.
Bug 2:
load_url_imagedidn't handle raw file IDsLocation:
backend/open_webui/routers/images.pyThe
load_url_imagefunction converts image URLs to base64 data before sending to the image editing API. It handled:http://orhttps:///api/v1/filesHowever, when an image is uploaded via the file upload API, the frontend sets
file.urlto just the file ID (e.g.,abc123-def456-...), not a full URL path. This caused the function to return the raw file ID unchanged, which is not valid image data for the editing API.Bug 3: Frontend only checked
type === 'image'in multiple componentsLocation: Multiple frontend components
Several components only checked
file.type === 'image'without also checkingcontent_type, causing uploaded images to be displayed as generic file icons instead of actual image previews.Bug 4: Edit mode used
file.urldirectly without URL transformationLocation:
src/lib/components/chat/Messages/UserMessage.svelteWhen editing a message and pasting/uploading an image, the edit mode was using
file.urldirectly (which could be a raw file ID) instead of constructing the proper API URL, resulting in broken image previews.Changes Made
Backend
1.
backend/open_webui/utils/middleware.pyUpdated
get_images_from_messages()to also check forcontent_typestarting with'image/':2. backend/open_webui/routers/images.py
Updated load_url_image() to handle raw file IDs by attempting to retrieve the file content:
Frontend
3. Updated image type detection in multiple components
Added content_type check to match the pattern already used in Chat.svelte and MessageInput.svelte:
Added URL transformation to edit mode to handle raw file IDs:
Additional Notes
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.