Last active
August 29, 2015 14:05
-
-
Save k0nsl/b0eb41a8a3a2f40263d7 to your computer and use it in GitHub Desktop.
Automatically embed YouTube links in phpBB3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Embed YouTube links automatically in phpBB3. | |
Original author: RMcGirr83 ([email protected]) | |
Edited by k0nsl ([email protected]) | |
--> | |
<script type="text/javascript"> | |
WebFontConfig = { | |
google: { families: [ 'Open+Sans::latin' ] } | |
}; | |
(function() { | |
var wf = document.createElement('script'); | |
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') + | |
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'; | |
wf.type = 'text/javascript'; | |
wf.async = 'true'; | |
var s = document.getElementsByTagName('script')[0]; | |
s.parentNode.insertBefore(wf, s); | |
})(); </script> | |
<style css="text/css"> | |
p{font-family:'Open Sans', sans-serif;} | |
</style> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
<script type="text/javascript" src="{ROOT_PATH}js/colorbox/jquery.colorbox-min.js"></script> | |
<link rel="stylesheet" href="{ROOT_PATH}js/colorbox/colorbox.css" type="text/css" /> | |
<script type="text/javascript"> | |
// <![CDATA[ | |
$(function(){ | |
$("a.postlink").filter(function(){if($(this).attr("href").match("(http|https)://(www.)?youtube|youtu.be|m.youtube")){youtube_id=$(this).attr("href").match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/)[2];$(this).html('<p style="text-align:center;"><img src="http://img.youtube.com/vi/'+youtube_id+'/2.jpg" /></p>'); var a=$(this).find("img");$.ajax({url:"http://gdata.youtube.com/feeds/api/videos/"+youtube_id+"?v=2&alt=jsonc",dataType:"json",success:function(b){$(a).after("<br />"+b.data.title+" "+b.data.duration+" seconds")}});return $(this).attr("href","http://www.youtube.com/embed/"+youtube_id+"?autoplay=1")}}).colorbox({iframe:!0,innerWidth:640,innerHeight:425}); | |
}); | |
// ]]> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment