From 1d70ecd80d591e98a3f0a422df3dfe2ace3b0f5d Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Fri, 23 May 2014 11:55:48 +0200 Subject: [PATCH] [IMP] website: add max_height and max_width options to image Qweb widget --- addons/website/models/ir_qweb.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/website/models/ir_qweb.py b/addons/website/models/ir_qweb.py index ad2b63a6dd9..40b407a040a 100644 --- a/addons/website/models/ir_qweb.py +++ b/addons/website/models/ir_qweb.py @@ -265,10 +265,16 @@ class Image(orm.AbstractModel): if options is None: options = {} classes = ['img', 'img-responsive'] + options.get('class', '').split() - return ir_qweb.HTMLSafe('' % ( + size_params = [] + if options.has_key('max_width'): + size_params.append("max_width=%i" % options['max_width']) + if options.has_key('max_height'): + size_params.append("max_height=%i" % options['max_height']) + + return ir_qweb.HTMLSafe('' % ( ' '.join(itertools.imap(werkzeug.utils.escape, classes)), record._model._name, - field_name, record.id)) + field_name, record.id, '&'.join(size_params))) local_url_re = re.compile(r'^/(?P[^]]+)/static/(?P.+)$') def from_html(self, cr, uid, model, column, element, context=None):