[FIX] web: correctly handle admin svg images in channel
When posting an svg image, Odoo tries to resize it for thumbnailing (like any image). However this is of no interest since this is a vectorial file format, and furthermore it distastefully makes the image library Pillow crash, since it only supports raster formats. The result would be a broken thumbnail instead of the image itself. By not setting the thumbnail size if the mimetype contains svg, we ignore the thumbnailing altogether. Note that this only applies to the admin user, as otherwise the file is treated as binary and thus no thumbnailing occurs anyway. opw 1841153
This commit is contained in:
@@ -1047,8 +1047,12 @@ class Binary(http.Controller):
|
||||
elif status != 200 and download:
|
||||
return request.not_found()
|
||||
|
||||
height = int(height or 0)
|
||||
width = int(width or 0)
|
||||
if headers and dict(headers).get('Content-Type', '') == 'image/svg+xml': # we shan't resize svg images
|
||||
height = 0
|
||||
width = 0
|
||||
else:
|
||||
height = int(height or 0)
|
||||
width = int(width or 0)
|
||||
|
||||
if crop and (width or height):
|
||||
content = crop_image(content, type='center', size=(width, height), ratio=(1, 1))
|
||||
|
||||
Reference in New Issue
Block a user