[FIX] website: correct image resizing
This commit is contained in:
parent
7d7f6fefb1
commit
f2cb8702b2
|
@ -399,10 +399,15 @@ class Website(openerp.addons.web.controllers.main.Home):
|
|||
The requested field is assumed to be base64-encoded image data in
|
||||
all cases.
|
||||
"""
|
||||
response = werkzeug.wrappers.Response()
|
||||
return request.registry['website']._image(
|
||||
request.cr, request.uid, model, id, field, response, max_width, max_height)
|
||||
|
||||
try:
|
||||
response = werkzeug.wrappers.Response()
|
||||
return request.registry['website']._image(
|
||||
request.cr, request.uid, model, id, field, response, max_width, max_height)
|
||||
except Exception:
|
||||
logger.exception("Cannot render image field %r of record %s[%s] at size(%s,%s)",
|
||||
field, model, id, max_width, max_height)
|
||||
response = werkzeug.wrappers.Response()
|
||||
return self.placeholder(response)
|
||||
|
||||
#------------------------------------------------------
|
||||
# Server actions
|
||||
|
|
|
@ -554,10 +554,8 @@ class website(osv.osv):
|
|||
response.mimetype = Image.MIME[image.format]
|
||||
|
||||
w, h = image.size
|
||||
try:
|
||||
max_w, max_h = int(max_width), int(max_height)
|
||||
except:
|
||||
max_w, max_h = (maxint, maxint)
|
||||
max_w = int(max_width) if max_width else maxint
|
||||
max_h = int(max_height) if max_height else maxint
|
||||
|
||||
if w < max_w and h < max_h:
|
||||
response.data = data
|
||||
|
|
Loading…
Reference in New Issue