]> git.wh0rd.org Git - tt-rss.git/commitdiff
af_redditimgur: embed youtube links
authorAndrew Dolgov <noreply@fakecake.org>
Mon, 6 Jul 2015 18:44:38 +0000 (21:44 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Mon, 6 Jul 2015 18:44:38 +0000 (21:44 +0300)
plugins/af_redditimgur/init.php

index 03418dc858714012f6c97b9695503deb551af0c3..28e3894d2e9d215a59db038fb3f85b259094e126 100644 (file)
@@ -84,6 +84,29 @@ class Af_RedditImgur extends Plugin {
                                                                $found = true;
                                                        }
 
+                                                       $matches = array();
+                                                       if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) ||
+                                                               preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
+                                                               preg_match("/\/\/youtu.be\/([\w-]+)/", $entry->getAttribute("href"), $matches)) {
+
+                                                               $vid_id = $matches[1];
+
+                                                               $iframe = $doc->createElement("iframe");
+                                                               $iframe->setAttribute("class", "youtube-player");
+                                                               $iframe->setAttribute("type", "text/html");
+                                                               $iframe->setAttribute("width", "640");
+                                                               $iframe->setAttribute("height", "385");
+                                                               $iframe->setAttribute("src", "https://www.youtube.com/embed/$vid_id");
+                                                               $iframe->setAttribute("allowfullscreen", "1");
+                                                               $iframe->setAttribute("frameborder", "0");
+
+                                                               $br = $doc->createElement('br');
+                                                               $entry->parentNode->insertBefore($iframe, $entry);
+                                                               $entry->parentNode->insertBefore($br, $entry);
+
+                                                               $found = true;
+                                                       }
+
                                                        if (preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href"))) {
                                                                $img = $doc->createElement('img');
                                                                $img->setAttribute("src", $entry->getAttribute("href"));