Browse Source

Merge pull request #222 from towards-a-new-leftypol/revert-217-youtubeEmbed

Revert "Replace Youtube embed"
pull/40/head
towards-a-new-leftypol 3 years ago
committed by GitHub
parent
commit
c10756c96f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      inc/instance-config.php
  2. 33
      js/youtube.js

2
inc/instance-config.php

@ -349,7 +349,7 @@ $config['enable_embedding'] = true;
$config['youtube_js_html'] = '<div class="video-container" data-video="$2">'.
'<a href="https://youtu.be/$2" target="_blank" class="file">'.
'https://youtu.be/$2'.
'<img style="width:255px;height:190px;" src="//img.youtube.com/vi/$2/0.jpg" class="post-image"/>'.
'</a></div>';
$config['embedding'] = array();

33
js/youtube.js

@ -25,32 +25,21 @@
onready(function(){
var do_embed_yt = function(tag) {
const ON = "[Remove]";
const OFF = "[Embed]";
$('div.video-container a', tag).click(function() {
var videoID = $(this.parentNode).data('video');
$(this.parentNode).html('<iframe style="float:left;margin: 10px 20px" type="text/html" '+
'width="360" height="270" src="//www.youtube.com/embed/' + videoID +
'?autoplay=1&html5=1" allowfullscreen frameborder="0"/>');
var videoNode = $('div.video-container', tag);
var videoId = videoNode.data('video');
var span = $("<span>[Embed]</span>");
var embedNode = $('<iframe style="float:left;margin: 10px 20px" type="text/html" '+
'width="360" height="270" src="//www.youtube.com/embed/' + videoId +
'?autoplay=1&html5=1" allowfullscreen frameborder="0"/>')
span.click(function() {
if (span.text() == ON){
embedNode.remove();
span.text(OFF);
} else{
videoNode.append(embedNode);
span.text(ON);
}
return false;
});
videoNode.append(span);
};
do_embed_yt(document);
// allow to work with auto-reload.js, etc.
$(document).on('new_post', function(e, post) {
do_embed_yt(post);
});
// allow to work with auto-reload.js, etc.
$(document).on('new_post', function(e, post) {
do_embed_yt(post);
});
});

Loading…
Cancel
Save