diff options
| author | Sébastien Theys <seb@odoo.com> | 2019-04-26 10:55:21 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2019-04-29 13:45:03 +0000 |
| commit | d870877967b5debc11d9364ba1572e7aa6956c28 (patch) | |
| tree | 59d3ba22c19dc6d40c8b266f012864bd952621f6 /addons/website_profile/controllers/main.py | |
| parent | b230114fcf41403cbb5fe353f1f94298c958cccc (diff) | |
[IMP] tools,base,web,website_*: keep image ratio on resize
* = website_partner, website_profile, website_sale, website_slides
Before
======
Since commit: 2e3848b394748bf23eff0db0d6d92b9e8c9bf875
The images that are resized have additional borders if the target ratio is
different than the image ratio. Those borders are transparent if the image
format supports it, and are white otherwise.
With that current solution, if the background where the image is displayed is
another color than white, it is looking really bad.
Moreover, most images are stored resized like this, so it is not even possible
to decide if it should have borders or not depending on the context, the
original image and ratio is forever lost.
It is also inconsistent because if the image is already smaller than the target
size then it doesn't include borders. In that case it keeps the original ratio
instead of the target ratio. So it isn't even guaranteed that the target
ratio is going to be respected.
After
=====
This commit will solve all of those problems by always keeping the ratio of the
original image.
This implies the views should be taking care of adding borders when necessary.
task-1958000
PR: #31811
Diffstat (limited to 'addons/website_profile/controllers/main.py')
| -rw-r--r-- | addons/website_profile/controllers/main.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/website_profile/controllers/main.py b/addons/website_profile/controllers/main.py index fc1e9b70715..a15f30ade18 100644 --- a/addons/website_profile/controllers/main.py +++ b/addons/website_profile/controllers/main.py @@ -80,7 +80,7 @@ class WebsiteProfile(http.Controller): @http.route([ '/profile/avatar/<int:user_id>', ], type='http', auth="public", website=True, sitemap=False) - def get_user_profile_avatar(self, user_id, field='image_large', width=0, height=0, crop=False, avoid_if_small=False, upper_limit=False, **post): + def get_user_profile_avatar(self, user_id, field='image_large', width=0, height=0, crop=False, **post): if field not in ('image_small', 'image_medium', 'image_large'): return werkzeug.exceptions.Forbidden() @@ -102,7 +102,7 @@ class WebsiteProfile(http.Controller): image_base64 = self._get_default_avatar(field, headers, width, height) image_base64 = tools.limited_image_resize( - image_base64, width=width, height=height, crop=crop, upper_limit=upper_limit, avoid_if_small=avoid_if_small) + image_base64, width=width, height=height, crop=crop) content = base64.b64decode(image_base64) headers.append(('Content-Length', len(content))) |
