]> git.wh0rd.org Git - tt-rss.git/commitdiff
af_redditimgur: reinstate img placeholder for <video> rewrites to auto-disable embedd...
authorAndrew Dolgov <noreply@fakecake.org>
Mon, 18 May 2015 09:05:30 +0000 (12:05 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Mon, 18 May 2015 09:06:21 +0000 (12:06 +0300)
plugins/af_redditimgur/init.php

index 83b56371e1d193a5186c91dbaa6fc698b4240aa4..71e6e3b0fa02e6189cd8f168578ae6edc4de89ee 100644 (file)
@@ -45,6 +45,12 @@ class Af_RedditImgur extends Plugin {
                                                                $entry->parentNode->insertBefore($video, $entry);
                                                                $entry->parentNode->insertBefore($br, $entry);
 
+                                                               $img = $doc->createElement('img');
+                                                               $img->setAttribute("src",
+                                                                       "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D");
+
+                                                               $entry->parentNode->insertBefore($img, $entry);
+
                                                                $found = true;
                                                        }
 
@@ -109,18 +115,24 @@ class Af_RedditImgur extends Plugin {
                                                                        if ($adoc) {
                                                                                $axpath = new DOMXPath($adoc);
                                                                                $aentries = $axpath->query("//meta[@property='og:image']");
+                                                                               $urls = array();
 
                                                                                foreach ($aentries as $aentry) {
-                                                                                       $img = $doc->createElement('img');
-                                                                                       $img->setAttribute("src", $aentry->getAttribute("content"));
-                                                                                       $entry->parentNode->insertBefore($doc->createElement('br'), $entry);
 
-                                                                                       $br = $doc->createElement('br');
+                                                                                       if (!in_array($aentry->getAttribute("content"), $urls)) {
+                                                                                               $img = $doc->createElement('img');
+                                                                                               $img->setAttribute("src", $aentry->getAttribute("content"));
+                                                                                               $entry->parentNode->insertBefore($doc->createElement('br'), $entry);
 
-                                                                                       $entry->parentNode->insertBefore($img, $entry);
-                                                                                       $entry->parentNode->insertBefore($br, $entry);
+                                                                                               $br = $doc->createElement('br');
 
-                                                                                       $found = true;
+                                                                                               $entry->parentNode->insertBefore($img, $entry);
+                                                                                               $entry->parentNode->insertBefore($br, $entry);
+
+                                                                                               array_push($urls, $aentry->getAttribute("content"));
+
+                                                                                               $found = true;
+                                                                                       }
                                                                                }
                                                                        }
                                                                }