]> git.wh0rd.org Git - tt-rss.git/commitdiff
redditimgur: iframes are garbage
authorAndrew Dolgov <noreply@fakecake.org>
Fri, 15 May 2015 05:13:47 +0000 (08:13 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Fri, 15 May 2015 05:13:47 +0000 (08:13 +0300)
plugins/af_redditimgur/init.php

index 7e65ef74b734dea864521a8401ecff404eee410b..83b56371e1d193a5186c91dbaa6fc698b4240aa4 100644 (file)
@@ -31,52 +31,21 @@ class Af_RedditImgur extends Plugin {
 
                                                        if (preg_match("/\.(gifv)$/i", $entry->getAttribute("href"))) {
 
-                                                               $gifv_meta = fetch_file_contents($entry->getAttribute("href"),
-                                                                       false, false, false, false, 10);
-
-                                                               if ($gifv_meta) {
-                                                                       $adoc = new DOMDocument();
-                                                                       @$adoc->loadHTML($gifv_meta);
-
-                                                                       if ($adoc) {
-                                                                               $axpath = new DOMXPath($adoc);
-                                                                               $aentries = $axpath->query('(//meta)');
+                                                               $video = $doc->createElement('video');
+                                                               $video->setAttribute("autoplay", "1");
+                                                               $video->setAttribute("loop", "1");
 
-                                                                               $width = false;
-                                                                               $height = false;
+                                                               $source = $doc->createElement('source');
+                                                               $source->setAttribute("src", str_replace(".gifv", ".mp4", $entry->getAttribute("href")));
+                                                               $source->setAttribute("type", "video/mp4");
 
-                                                                               foreach ($aentries as $aentry) {
-                                                                                       if (strpos($aentry->getAttribute("property"), "og:image:width") !== FALSE) {
-                                                                                               $width = $aentry->getAttribute("content");
-                                                                                       }
+                                                               $video->appendChild($source);
 
-                                                                                       if (strpos($aentry->getAttribute("property"), "og:image:height") !== FALSE) {
-                                                                                               $height = $aentry->getAttribute("content");
-                                                                                       }
-                                                                               }
-                                                                       }
-                                                               }
+                                                               $br = $doc->createElement('br');
+                                                               $entry->parentNode->insertBefore($video, $entry);
+                                                               $entry->parentNode->insertBefore($br, $entry);
 
-                                                               if ($width && $height) {
-
-                                                                       $iframe = $doc->createElement('iframe');
-                                                                       $iframe->setAttribute("src", str_replace("http:", "", $entry->getAttribute("href")));
-                                                                       $iframe->setAttribute("frameborder", "0");
-                                                                       $iframe->setAttribute("width", $width + 64);
-                                                                       $iframe->setAttribute("height", $height + 64);
-
-                                                                       $br = $doc->createElement('br');
-                                                                       $entry->parentNode->insertBefore($iframe, $entry);
-                                                                       $entry->parentNode->insertBefore($br, $entry);
-
-                                                                       // add empty img tag to disable display of attachment
-                                                                       $img = $doc->createElement('img');
-                                                                       $img->setAttribute("src", "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D");
-                                                                       $img->setAttribute("width", "0");
-                                                                       $img->setAttribute("height", "0");
-                                                                       $entry->parentNode->insertBefore($img, $entry);
-                                                                       $found = true;
-                                                               }
+                                                               $found = true;
                                                        }
 
                                                        if (preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9])?$/i", $entry->getAttribute("href"))) {