From f2cb8702b231621abf34d343b49ae8a711f776d1 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 6 Aug 2014 16:20:22 +0200 Subject: [PATCH] [FIX] website: correct image resizing --- addons/website/controllers/main.py | 13 +++++++++---- addons/website/models/website.py | 6 ++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 0ba7c3224c9..7810f179af8 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -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 diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 5921e6cfca4..6eb72b9cd5a 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -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