| Line 335: |
Line 335: |
| | //}) | | //}) |
| | | | |
| − | // Basic webp/webm/ogg/mp4 video support using <img> and <video> in elements with respective classes | + | // Basic video support using <img> and <video> elements |
| | | | |
| − | $('.webp').each(function () { | + | $('.video').each(function () { |
| − | var a = $('<a>').addClass('image').attr('href', '/File:' + $(this).data('src')); | + | var src = $(this).data('src') || ''; |
| − | var img = $('<img>');
| + | var parts = src.split('.'); |
| − | for (var attr in $(this).data()) {
| + | var ext = parts[parts.length - 1] || ''; |
| − | img.attr(attr, (attr === 'src' ? 'https://kcwiki-en.mirairepository.net/Special:Filepath/' : '') + $(this).data(attr));
| + | if (ext === 'webp') { |
| − | }
| + | var a = $('<a>').addClass('image').attr('href', '/File:' + src); |
| − | a.append(img);
| + | var img = $('<img>'); |
| − | $(this).append(a);
| + | for (var attr in $(this).data()) { |
| − | });
| + | img.attr(attr, (attr === 'src' ? 'https://kcwiki-en.mirairepository.net/Special:Filepath/' : '') + $(this).data(attr)); |
| − | | + | } |
| − | for (var ext of ['webm', 'ogg', 'mp4']) {
| + | a.append(img); |
| − | $('.' + ext).each(function () {
| + | $(this).append(a); |
| | + | } else { |
| | var video = $('<video>').attr('controls'); | | var video = $('<video>').attr('controls'); |
| | var source = $('<source>').attr('type', 'video/' + ext); | | var source = $('<source>').attr('type', 'video/' + ext); |
| Line 357: |
Line 358: |
| | video.append(source); | | video.append(source); |
| | $(this).append(video); | | $(this).append(video); |
| − | }); | + | } |
| − | } | + | }); |
| | | | |
| | }); | | }); |