Handle nio.ThumbnailError cases
Return a 1x1 transparent PNG for now.
This commit is contained in:
parent
44a998f31b
commit
4c0b947d1a
3
TODO.md
3
TODO.md
|
@ -3,8 +3,6 @@
|
||||||
- Accent color from background
|
- Accent color from background
|
||||||
- Reduce messages ListView cacheBuffer height once http thumbnails
|
- Reduce messages ListView cacheBuffer height once http thumbnails
|
||||||
downloading is implemented
|
downloading is implemented
|
||||||
- Button can get "hoverEnabled: false" to let HoverHandlers work
|
|
||||||
- Handle thumbnail response status 400
|
|
||||||
- Improve avatar tooltips position, add stuff to room tooltips (last msg?)
|
- Improve avatar tooltips position, add stuff to room tooltips (last msg?)
|
||||||
- Accept drag and dropping a picture in account settings to set avatar
|
- Accept drag and dropping a picture in account settings to set avatar
|
||||||
- When all the events loaded on beginning in a room are name/avatar changes,
|
- When all the events loaded on beginning in a room are name/avatar changes,
|
||||||
|
@ -18,6 +16,7 @@
|
||||||
- Refactoring
|
- Refactoring
|
||||||
- Don't bake in size properties for components
|
- Don't bake in size properties for components
|
||||||
- Unfinished work in button-refactor branch
|
- Unfinished work in button-refactor branch
|
||||||
|
- Button can get "hoverEnabled: false" to let HoverHandlers work
|
||||||
- Room Sidepane
|
- Room Sidepane
|
||||||
|
|
||||||
- Bug fixes
|
- Bug fixes
|
||||||
|
|
|
@ -92,6 +92,13 @@ class Thumbnail:
|
||||||
height = self.server_size[1],
|
height = self.server_size[1],
|
||||||
method = self.resize_method,
|
method = self.resize_method,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if isinstance(response, nio.ThumbnailError):
|
||||||
|
# Return a transparent 1x1 PNG
|
||||||
|
with BytesIO() as img_out:
|
||||||
|
PILImage.new("RGBA", (1, 1), (0, 0, 0, 0)).save(img_out, "PNG")
|
||||||
|
return img_out.getvalue()
|
||||||
|
|
||||||
body = response.body
|
body = response.body
|
||||||
|
|
||||||
if response.content_type not in ("image/jpeg", "image/png"):
|
if response.content_type not in ("image/jpeg", "image/png"):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user