af_redditimgur: reinstate img placeholder for <video> rewrites to auto-disable embedding attachments, ignore duplicate images when embedding album links

This commit is contained in:
Andrew Dolgov 2015-05-18 12:05:30 +03:00
parent 1929149661
commit 98e2051086
1 changed files with 19 additions and 7 deletions

View File

@ -45,6 +45,12 @@ class Af_RedditImgur extends Plugin {
$entry->parentNode->insertBefore($video, $entry); $entry->parentNode->insertBefore($video, $entry);
$entry->parentNode->insertBefore($br, $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; $found = true;
} }
@ -109,8 +115,11 @@ class Af_RedditImgur extends Plugin {
if ($adoc) { if ($adoc) {
$axpath = new DOMXPath($adoc); $axpath = new DOMXPath($adoc);
$aentries = $axpath->query("//meta[@property='og:image']"); $aentries = $axpath->query("//meta[@property='og:image']");
$urls = array();
foreach ($aentries as $aentry) { foreach ($aentries as $aentry) {
if (!in_array($aentry->getAttribute("content"), $urls)) {
$img = $doc->createElement('img'); $img = $doc->createElement('img');
$img->setAttribute("src", $aentry->getAttribute("content")); $img->setAttribute("src", $aentry->getAttribute("content"));
$entry->parentNode->insertBefore($doc->createElement('br'), $entry); $entry->parentNode->insertBefore($doc->createElement('br'), $entry);
@ -120,12 +129,15 @@ class Af_RedditImgur extends Plugin {
$entry->parentNode->insertBefore($img, $entry); $entry->parentNode->insertBefore($img, $entry);
$entry->parentNode->insertBefore($br, $entry); $entry->parentNode->insertBefore($br, $entry);
array_push($urls, $aentry->getAttribute("content"));
$found = true; $found = true;
} }
} }
} }
} }
} }
}
// remove tiny thumbnails // remove tiny thumbnails
if ($entry->hasAttribute("src")) { if ($entry->hasAttribute("src")) {