From cdf2ef5f4da146b195335b3d2cc51269e64385d7 Mon Sep 17 00:00:00 2001
From: weru <fromweru@gmail.com>
Date: Thu, 11 Jan 2024 17:49:42 +0000
Subject: [PATCH] allow external image in gallery #132

---
 layouts/shortcodes/gallery.html |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/layouts/shortcodes/gallery.html b/layouts/shortcodes/gallery.html
index b28c623..6413cbb 100644
--- a/layouts/shortcodes/gallery.html
+++ b/layouts/shortcodes/gallery.html
@@ -1,9 +1,12 @@
 {{- $images := split (replace (.Get 0) ", " ",") "," }}
 {{- $descriptions := split (replace (.Get 1) ":: " "::") "::" }}
 <div class="gallery">
-  {{ range $index, $image := $images }}
-  <figure class="gallery_item">
-    <img src="{{ absURL $image }} " class="gallery_image"{{ with $descriptions }}{{ with (index . $index) }} alt="{{ . }}"{{ end }}{{ end }}/>
-  </figure>
+  {{- range $index, $image := $images }}
+    {{- if eq ((strings.Contains $image "https://") || (strings.Contains $image "http://")) true }}
+      {{- $image = absURL $image }}
+    {{- end }} 
+    <figure class="gallery_item">
+      <img src="{{ $image }} " class="gallery_image"{{ with $descriptions }}{{ with (index . $index) }} alt="{{ . }}"{{ end }}{{ end }}/>
+    </figure>
   {{ end }}
 </div>

--
Gitblit v1.10.0