]> git.wh0rd.org - tt-rss.git/blob - plugins/af_youtube_embed/init.php
add HOOK_RENDER_ENCLOSURE & af_youtube_embed plugin
[tt-rss.git] / plugins / af_youtube_embed / init.php
1 <?php
2 class Af_Youtube_Embed extends Plugin {
3 private $host;
4
5 function about() {
6 return array(1.0,
7 "Embed videos in Youtube RSS feeds",
8 "fox");
9 }
10
11 function init($host) {
12 $this->host = $host;
13
14 $host->add_hook($host::HOOK_RENDER_ENCLOSURE, $this);
15 }
16
17 function hook_render_enclosure($entry, $hide_images) {
18
19 $matches = array();
20
21 if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry["url"], $matches) ||
22 preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry["url"], $matches) ||
23 preg_match("/\/\/youtu.be\/([\w-]+)/", $entry["url"], $matches)) {
24
25 $vid_id = $matches[1];
26
27 return "<iframe class=\"youtube-player\"
28 type=\"text/html\" width=\"640\" height=\"385\"
29 src=\"https://www.youtube.com/embed/$vid_id\"
30 allowfullscreen frameborder=\"0\"></iframe>";
31
32 }
33 }
34
35 function api_version() {
36 return 2;
37 }
38
39 }
40 ?>