]> git.wh0rd.org - tt-rss.git/blame - plugins/af_youtube_embed/init.php
feedbrowser hack
[tt-rss.git] / plugins / af_youtube_embed / init.php
CommitLineData
945346cb
AD
1<?php
2class 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
21ce7d9e
AD
17 /**
18 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
19 */
945346cb
AD
20 function hook_render_enclosure($entry, $hide_images) {
21
22 $matches = array();
23
24 if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry["url"], $matches) ||
25 preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry["url"], $matches) ||
26 preg_match("/\/\/youtu.be\/([\w-]+)/", $entry["url"], $matches)) {
27
28 $vid_id = $matches[1];
29
30 return "<iframe class=\"youtube-player\"
31 type=\"text/html\" width=\"640\" height=\"385\"
32 src=\"https://www.youtube.com/embed/$vid_id\"
33 allowfullscreen frameborder=\"0\"></iframe>";
34
35 }
36 }
37
38 function api_version() {
39 return 2;
40 }
41
42}