From 5d416152174d740aaa4b4e86a98f4dbd421ac541 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 8 Aug 2012 11:15:32 +0200 Subject: [PATCH] [FIX] fixed problems with images in kanban o2m bzr revid: nicolas.vanhoren@openerp.com-20120808091532-zjnvgpx33nkwj1z8 --- addons/web/static/src/js/view_form.js | 2 +- addons/web_kanban/static/src/js/kanban.js | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index c3f941305d5..8276a1b219c 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4606,7 +4606,7 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({ }, render_value: function() { var url; - if (this.get('value') && this.get('value').substr(0, 10).indexOf(' ') == -1) { + if (this.get('value') && ! /^\d+(\.\d*)? \w+$/.test(this.get('value'))) { url = 'data:image/png;base64,' + this.get('value'); } else if (this.get('value')) { url = '/web/binary/image?session_id=' + this.session.session_id + '&model=' + diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 4856c5d174a..8761b88690f 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -750,14 +750,17 @@ instance.web_kanban.KanbanRecord = instance.web.OldWidget.extend({ return 'http://www.gravatar.com/avatar/' + email_md5 + '.png?s=' + size + '&d=' + default_; }, kanban_image: function(model, field, id, cache) { - id = id || ''; - var url = instance.connection.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + id; - if (cache !== undefined) { - // Set the cache duration in seconds. - url += '&cache=' + parseInt(cache, 10); - } + var url; if (this.record[field] && this.record[field].value && ! /^\d+(\.\d*)? \w+$/.test(this.record[field].value)) { url = 'data:image/png;base64,' + this.record[field].value; + } else if (this.record[field] && ! this.record[field].value) { + url = "/web/static/src/img/placeholder.png"; + } else { + url = instance.connection.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + id; + if (cache !== undefined) { + // Set the cache duration in seconds. + url += '&cache=' + parseInt(cache, 10); + } } return url; },