From 9fdce50cbb073d9dda86cb2856d60d23dafd20a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Mon, 30 Dec 2024 22:21:03 +0100 Subject: [PATCH] make img clickable to event details --- js/ct-events.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/js/ct-events.js b/js/ct-events.js index 7f60d1e..9820ead 100644 --- a/js/ct-events.js +++ b/js/ct-events.js @@ -16,15 +16,23 @@ var AppointmentImage = { const {item, settings} = vnode.attrs; const image_url = item.base.image?.fileUrl ?? (is_mobile ? default_image_mobile : null) ?? settings.default_image; - return m(".cte-image", - image_url ? m( - "img", - { - src: image_url, - alt: item.base.caption, - }, - ) : null, - ) + let url = item.base.link; + if (url && !url.startsWith("http")) { + url = "https://" + url; + } + + let img = image_url ? m( + "img", + { + src: image_url, + alt: item.base.caption, + }, + ) : null; + if (img && url) { + img = m("a", {href: url}, img); + } + + return m(".cte-image", img) } }