diff --git a/js/gallery-view.js b/js/gallery-view.js
index 65a1e967..2d7d85b4 100644
--- a/js/gallery-view.js
+++ b/js/gallery-view.js
@@ -95,7 +95,7 @@ $(function(){
$('#gallery_images img.active').removeClass('active');
- var thumb = $('#gallery_images img[data-galid-th="'+a+'"]');
+ var thumb = $('#gallery_images [data-galid-th="'+a+'"]');
var elem = $('a[data-galid="'+a+'"]');
thumb.addClass('active');
@@ -107,16 +107,42 @@ $(function(){
var img = elem.attr('href');
- active.find('img').fadeOut(200, function() { $(this).remove(); });
+ active.find('img, video').fadeOut(200, function() { $(this).remove(); });
- var i = $('
');
- i.attr('src', img);
- i.appendTo(active);
- i.hide();
+ var i;
+ if (img.match(/player\.php/)) {
+ img = img.replace(/.*player\.php\?v=|&t=.*/g, '');
+ }
+ if (img.match(/\.webm$|\.mp4$|\.ogv$/i)) { // We are handling video nao
+ i = $('