|
@@ -208,7 +208,8 @@ def printRobotMenuDeutsch():
|
208
|
208
|
# lightgallery helper macro
|
209
|
209
|
# -----------------------------------------------------------------------------
|
210
|
210
|
|
211
|
|
-# call this macro like this
|
|
211
|
+# call this macro like this:
|
|
212
|
+
|
212
|
213
|
# lightgallery([
|
213
|
214
|
# [ "image-link", "description" ],
|
214
|
215
|
# [ "image-link", "thumbnail-link", "description" ],
|
|
@@ -216,6 +217,34 @@ def printRobotMenuDeutsch():
|
216
|
217
|
# [ "video-link", "mime", "thumbnail-link", "image-link", "description" ]
|
217
|
218
|
# ])
|
218
|
219
|
|
|
220
|
+# it will also auto-generate thumbnails and resize and strip EXIF from images
|
|
221
|
+# using the included web-image-resize script.
|
|
222
|
+
|
|
223
|
+def lightgallery_check_thumbnail(link, thumb):
|
|
224
|
+ # only check local image links
|
|
225
|
+ if not link.startswith('img/'):
|
|
226
|
+ return
|
|
227
|
+
|
|
228
|
+ # generate thumbnail filename web-image-resize will create
|
|
229
|
+ x = link.rfind('.')
|
|
230
|
+ img = link[:x] + '_small' + link[x:]
|
|
231
|
+
|
|
232
|
+ # only run when desired thumb path matches calculated ones
|
|
233
|
+ if thumb != img:
|
|
234
|
+ return
|
|
235
|
+
|
|
236
|
+ # generate fs path to images
|
|
237
|
+ path = os.path.join(os.getcwd(), 'static', link)
|
|
238
|
+ img = os.path.join(os.getcwd(), 'static', thumb)
|
|
239
|
+
|
|
240
|
+ # no need to generate thumb again
|
|
241
|
+ if os.path.exists(img):
|
|
242
|
+ return
|
|
243
|
+
|
|
244
|
+ # run web-image-resize to generate thumbnail
|
|
245
|
+ script = os.path.join(os.getcwd(), 'web-image-resize')
|
|
246
|
+ os.system(script + ' ' + path)
|
|
247
|
+
|
219
|
248
|
def lightgallery(links):
|
220
|
249
|
videos = [l for l in links if len(l) == 5]
|
221
|
250
|
v_i = -1
|
|
@@ -240,6 +269,7 @@ def lightgallery(links):
|
240
|
269
|
link, alt = l
|
241
|
270
|
x = link.rfind('.')
|
242
|
271
|
img = link[:x] + '_small' + link[x:]
|
|
272
|
+ lightgallery_check_thumbnail(link, img)
|
243
|
273
|
print '<div class="border" data-src="' + link + '"><a href="' + link + '"><img class="pic" src="' + img + '" alt="' + alt + '"></a></div>'
|
244
|
274
|
elif len(l) == 5:
|
245
|
275
|
v_i += 1
|