Skip to content

Instantly share code, notes, and snippets.

@Mad182
Last active January 3, 2016 01:19
Show Gist options
  • Save Mad182/8388401 to your computer and use it in GitHub Desktop.
Save Mad182/8388401 to your computer and use it in GitHub Desktop.
yt embed
function embed_youtube($params) {
var_dump($params);
//druka ārā embed kodu,
//var atvilkt title un sīkbildi caur api,
//pieglabāt lokāli, vai ko nu katram vajag
}
$txt = preg_replace_callback("#(^|[\n ]|<a(.*?)>)https?://(www\.)?youtube\.com/watch\?v=([a-zA-Z0-9\-_]+)((.*?)</a>)?#im", embed_youtube, $txt);
$txt = preg_replace_callback("#(^|[\n ]|<a(.*?)>)https?://(www\.)?youtu\.be/([a-zA-Z0-9\-_]+)((.*?)</a>)?#im", embed_youtube, $txt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment