fix: JPEG and WebP images from a model are stored inside the chat instead of as files (#31975)

When a model returned an image, only PNG was saved as a file. JPEG and WebP images stayed as raw base64 data inside the chat in the database, so a 1.5 MB JPEG made the stored chat 1.5 MB larger. These images are now saved as files and the chat keeps only a link to them, the same way PNG already worked.

Fixes #31916
This commit is contained in:
Classic298 2026-10-07 13:47:01 +02:00 • committed by GitHub
parent f5399ea2d2
commit bcf99374f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1766,7 +1766,7 @@ async def get_image_urls(delta_images, request, metadata, user) -> list[str]:
if not url:
continue
if url.startswith('data:image/png;base64'):
if re.match(r'data:image/\w+;base64', url):
url = await get_image_url_from_base64(request, url, metadata, user)
image_urls.append(url)