From 4532221717700a1c43556923646b656fcf4ca662 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 da78a37553..9c925b0845 100644 --- a/api/js/etemplate/et2_widget_image.js +++ b/api/js/etemplate/et2_widget_image.js @@ -365,6 +365,8 @@ var et2_avatar = (function(){ "use strict"; return et2_image.extend( }; var id = 'contact_id'; + this.image.addClass('et2_avatar'); + if (!_contact_id) { _contact_id = this.egw().user('account_id'); @@ -380,8 +382,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('/index.php',params); this.set_src(url);