[FIX] web: company logo file extension
The company logo file extension is always '.png', even if the logo is of another type such as 'jpg' or 'gif'. This is not an issue for decent browsers, but IE might not display the image under specific circumstancies, e.g. in combination with nginx. opw-676836
This commit is contained in:
@@ -4,6 +4,7 @@ import base64
|
||||
import csv
|
||||
import functools
|
||||
import glob
|
||||
import imghdr
|
||||
import itertools
|
||||
import jinja2
|
||||
import logging
|
||||
@@ -1077,7 +1078,8 @@ class Binary(http.Controller):
|
||||
'/logo.png',
|
||||
], type='http', auth="none", cors="*")
|
||||
def company_logo(self, dbname=None, **kw):
|
||||
imgname = 'logo.png'
|
||||
imgname = 'logo'
|
||||
imgext = '.png'
|
||||
placeholder = functools.partial(get_resource_path, 'web', 'static', 'src', 'img')
|
||||
uid = None
|
||||
if request.session.db:
|
||||
@@ -1090,7 +1092,7 @@ class Binary(http.Controller):
|
||||
uid = openerp.SUPERUSER_ID
|
||||
|
||||
if not dbname:
|
||||
response = http.send_file(placeholder(imgname))
|
||||
response = http.send_file(placeholder(imgname + imgext))
|
||||
else:
|
||||
try:
|
||||
# create an empty registry
|
||||
@@ -1104,12 +1106,14 @@ class Binary(http.Controller):
|
||||
""", (uid,))
|
||||
row = cr.fetchone()
|
||||
if row and row[0]:
|
||||
image_data = StringIO(str(row[0]).decode('base64'))
|
||||
response = http.send_file(image_data, filename=imgname, mtime=row[1])
|
||||
image_base64 = str(row[0]).decode('base64')
|
||||
image_data = StringIO(image_base64)
|
||||
imgext = '.' + (imghdr.what(None, h=image_base64) or 'png')
|
||||
response = http.send_file(image_data, filename=imgname + imgext, mtime=row[1])
|
||||
else:
|
||||
response = http.send_file(placeholder('nologo.png'))
|
||||
except Exception:
|
||||
response = http.send_file(placeholder(imgname))
|
||||
response = http.send_file(placeholder(imgname + imgext))
|
||||
|
||||
return response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user