summaryrefslogtreecommitdiff
path: root/addons/web_editor/models/ir_qweb.py
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2016-09-14 16:47:07 +0200
committerJeremy Kersten <jke@odoo.com>2016-09-21 21:29:18 +0200
commitf0463a3e1dcc12f3ff7c9c4f24295ad7dd46760e (patch)
tree9a3f29f286a2b260b5624d159ad8945574428fb0 /addons/web_editor/models/ir_qweb.py
parentfd36e5ceda035d6ac9efcc221bc6190169eae5ce (diff)
[IMP] web_editor, website, website_sale: add zoom option for t-field image
web_editor Qweb: Add 'zoom' option for widget image <span t-field="product.image_small" t-options="{'widget': 'image', 'zoom': 'image_medium'}" /> website: Add Zoom code to be standard for all website module website_sale: add zoom on Main product image
Diffstat (limited to 'addons/web_editor/models/ir_qweb.py')
-rw-r--r--addons/web_editor/models/ir_qweb.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/addons/web_editor/models/ir_qweb.py b/addons/web_editor/models/ir_qweb.py
index 214e66de796..751767800d6 100644
--- a/addons/web_editor/models/ir_qweb.py
+++ b/addons/web_editor/models/ir_qweb.py
@@ -303,8 +303,14 @@ class Image(models.AbstractModel):
elif options.get('alt'):
alt = options['alt']
- img = '<img class="%s" src="%s" style="%s"%s/>' % \
- (classes, src, options.get('style', ''), ' alt="%s"' % alt if alt else '')
+ src_zoom = None
+ if options.get('zoom') and getattr(record, options['zoom'], None):
+ src_zoom = '/web/image/%s/%s/%s%s?unique=%s' % (record._name, record.id, options['zoom'], max_size, sha)
+ elif options.get('zoom'):
+ src_zoom = options['zoom']
+
+ img = '<img class="%s" src="%s" style="%s"%s%s/>' % \
+ (classes, src, options.get('style', ''), ' alt="%s"' % alt if alt else '', ' data-zoom="1" data-zoom-image="%s"' % src_zoom if src_zoom else '')
return ir_qweb.unicodifier(img)
local_url_re = re.compile(r'^/(?P<module>[^]]+)/static/(?P<rest>.+)$')