diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 0ba7c3224c954393ed8b1b5abdf4a67ab6d40731..7810f179af898cb833ade08fad99318725676900 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 5921e6cfca42e2d2d90a54bc2d4d4b5b75371075..6eb72b9cd5a1769d9918f03920f169ff2706c9e6 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