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

Loading…
Cancel
Save