summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2018-10-11 17:02:47 +0000
committerChristophe Simonis <chs@odoo.com>2018-11-06 18:37:29 +0100
commitae3997b8bf7e539f91a64870ced76868550bae12 (patch)
tree793dab7381b2de5d72a4b8e955a8bccf55626fba /addons/web
parenteaa93d1bd491b41b92d50fb1c0f6f6a5e1596557 (diff)
[FIX] web: guess resize placeholder
Before this commit, if you ask for a small image, you was waiting a picture of 64x64 but in case this image was not found, a placeholder with an other size was returned. Now, we try to guess the asked size, and return a resized placeholder. This bug appear since we change the default placeholder picture with a big one This will fix several issue and avoid to hard code size everywhere in the code Eg: commit 92f837c and commit https://github.com/odoo/odoo/commit/154fc7d9dd550d35b7266af024e54c20e18938fc#diff-9af1af2039d16d6b544d481b4ee1ed7cR144 closes odoo/odoo#27695
Diffstat (limited to 'addons/web')
-rw-r--r--addons/web/controllers/main.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index 35332e4fe79..cc162d57ded 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -1073,7 +1073,12 @@ class Binary(http.Controller):
if content:
image_base64 = base64.b64decode(content)
else:
- image_base64 = self.placeholder(image='placeholder.png') # could return (contenttype, content) in master
+ suffix = field.split('_')[-1]
+ if suffix in ('small', 'medium', 'big'):
+ encoded_placeholder = base64.b64encode(self.placeholder(image='placeholder.png'))
+ image_base64 = base64.b64decode(getattr(odoo.tools, 'image_resize_image_%s' % suffix)(encoded_placeholder))
+ else:
+ image_base64 = self.placeholder(image='placeholder.png') # could return (contenttype, content) in master
headers = self.force_contenttype(headers, contenttype='image/png')
headers.append(('Content-Length', len(image_base64)))