diff options
| author | Parth Gajjar <pga@openerp.com> | 2017-11-16 12:40:22 +0530 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2018-03-15 11:30:53 +0100 |
| commit | 964e16a7f5598b6f2f5be75c9e591deabfaeccff (patch) | |
| tree | 45f6fabec74dc918f653425e9e7f6bc52bdf3646 /addons/web/controllers | |
| parent | f2f2dfaf3695cd6f1ca694c3e6b42a6ae011360d (diff) | |
[IMP] web: support famous 'avoid_if_small' parameter in image controller and qweb field options
Before this commit there was no option to avoid resizing images when it
was smaller than expected size. This leads to several image being displayed
with extra and unnecessary padding due to resize. This option will allow
to avoid that behavior by allowing to propagate the parameter directly
to image_resize_image.
This commit is related to task ID 31994 .
Diffstat (limited to 'addons/web/controllers')
| -rw-r--r-- | addons/web/controllers/main.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 6af25b7eaa0..fd24d253c21 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1031,7 +1031,7 @@ class Binary(http.Controller): '/web/image/<int:id>-<string:unique>/<int:width>x<int:height>/<string:filename>'], type='http', auth="public") def content_image(self, xmlid=None, model='ir.attachment', id=None, field='datas', filename_field='datas_fname', unique=None, filename=None, mimetype=None, - download=None, width=0, height=0, crop=False, access_token=None): + download=None, width=0, height=0, crop=False, access_token=None, avoid_if_small=False): status, headers, content = binary_content( xmlid=xmlid, model=model, id=id, field=field, unique=unique, filename=filename, filename_field=filename_field, download=download, mimetype=mimetype, @@ -1055,7 +1055,7 @@ class Binary(http.Controller): width = 500 if height > 500: height = 500 - content = odoo.tools.image_resize_image(base64_source=content, size=(width or None, height or None), encoding='base64', filetype='PNG') + content = odoo.tools.image_resize_image(base64_source=content, size=(width or None, height or None), encoding='base64', filetype='PNG', avoid_if_small=avoid_if_small) # resize force png as filetype headers = self.force_contenttype(headers, contenttype='image/png') |
