From 790d96eb150d02a32210d94bb80188a405be8708 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 20 Feb 2019 17:08:40 +0100 Subject: [PATCH] prefer source attribute (with cache-buster) over contact_id add cache-buster, if we have just a contact_id --- api/js/etemplate/et2_widget_image.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/api/js/etemplate/et2_widget_image.js b/api/js/etemplate/et2_widget_image.js index 6bdaae6b25..e82cfc7010 100644 --- a/api/js/etemplate/et2_widget_image.js +++ b/api/js/etemplate/et2_widget_image.js @@ -363,6 +363,8 @@ var et2_avatar = (function(){ "use strict"; return et2_image.extend( var params = {}; var id = 'contact_id'; + this.image.addClass('et2_avatar'); + if (!_contact_id) { _contact_id = this.egw().user('account_id'); @@ -378,8 +380,15 @@ var et2_avatar = (function(){ "use strict"; return et2_image.extend( _contact_id = _contact_id.replace('contact:', ''); } + // if our src (incl. cache-buster) already includes the correct id, use that one + if (this.options.src && this.options.src.match("(&|\\?)contact_id="+_contact_id+"(&|\\$)")) + { + return; + } + + // we have only the id, so we need to bypass caching with a cache-buster params[id] = _contact_id; - this.image.addClass('et2_avatar'); + params._cache = (new Date).getTime(); var url = egw.link('/api/avatar.php',params); this.set_src(url);