Browse Source

fix for multiple lightgallery blocks on one page with videos in each

Thomas Buck 1 year ago
parent
commit
5edc4f359f
1 changed files with 9 additions and 3 deletions
  1. 9
    3
      macros.py

+ 9
- 3
macros.py View File

@@ -307,15 +307,21 @@ def lightgallery_check_thumbnail_video(link, thumb, poster):
307 307
     os.system(script + ' ' + path)
308 308
 
309 309
 def lightgallery(links):
310
+    global v_ii
311
+    try:
312
+        v_ii += 1
313
+    except NameError:
314
+        v_ii = 0
315
+
310 316
     videos = [l for l in links if len(l) == 5]
311 317
     v_i = -1
312 318
     for v in videos:
313 319
         link, mime, thumb, poster, alt = v
314 320
         v_i += 1
315
-        print '<div style="display:none;" id="video' + str(v_i) + '">'
321
+        print '<div style="display:none;" id="video' + str(v_i) + '_' + str(v_ii) + '">'
316 322
         print '<video class="lg-video-object lg-html5" controls preload="none">'
317 323
         print '<source src="' + link + '" type="' + mime + '">'
318
-        print 'Your browser does not support HTML5 video.'
324
+        print '<a href="' + link + '">' + alt + '</a>'
319 325
         print '</video>'
320 326
         print '</div>'
321 327
         
@@ -351,7 +357,7 @@ def lightgallery(links):
351 357
                 x = link.rfind('.')
352 358
                 poster = link[:x] + '_poster.png'
353 359
             lightgallery_check_thumbnail_video(link, thumb, poster)
354
-            print '<div class="border" data-poster="' + poster + '" data-sub-html="' + alt + '" data-html="#video' + str(v_i) + '"><a href="' + link + '"><img class="pic" src="' + thumb + '"></a></div>'
360
+            print '<div class="border" data-poster="' + poster + '" data-sub-html="' + alt + '" data-html="#video' + str(v_i) + '_' + str(v_ii) + '"><a href="' + link + '"><img class="pic" src="' + thumb + '"></a></div>'
355 361
         else:
356 362
             raise NameError('Invalid number of arguments for lightgallery')
357 363
     print '</div>'

Loading…
Cancel
Save