From e265874bd7152c97e66ba5b1036aa9e72040c2ea Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 14 Jan 2014 16:07:39 +0000 Subject: [PATCH] new method to create object tag for svg and img for all other image types --- phpgwapi/js/jsapi/egw_images.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/phpgwapi/js/jsapi/egw_images.js b/phpgwapi/js/jsapi/egw_images.js index 8b974444d2..48e0de8031 100644 --- a/phpgwapi/js/jsapi/egw_images.js +++ b/phpgwapi/js/jsapi/egw_images.js @@ -129,6 +129,31 @@ egw.extend('images', egw.MODULE_GLOBAL, function() { } } return image; + }, + + /** + * Create DOM img or svn element depending on url + * + * @param {string} _url source url + * @param {string} _alt alt attribute for img tag + * @returns DOM node + */ + image_element: function(_url, _alt) + { + var icon; + if (_url.match(/\.svg$/)) + { + icon = document.createElement('object'); + icon.type = 'image/svg+xml'; + icon.data = _url; + } + else + { + icon = document.createElement('img'); + icon.src = _url; + if (_alt) icon.alt = _alt; + } + return icon; } } });