diff options
author | Andrew Dolgov <[email protected]> | 2015-10-17 22:11:12 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2015-10-17 22:11:12 +0300 |
commit | 58a44ecb3f789f6e06562b34bb0e3f65e3dd0e87 (patch) | |
tree | b2247fd6c3bd3c60cc96dd07689b1baf649dcce2 /plugins | |
parent | 583f163f40852c8067708a0a69e38e9c27318179 (diff) |
af_redditimgur: support gyazo, properly check album domdocuments loading html
Diffstat (limited to 'plugins')
-rwxr-xr-x[-rw-r--r--] | plugins/af_redditimgur/init.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index ded98d8cc..051d51780 100644..100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -88,9 +88,8 @@ class Af_RedditImgur extends Plugin { if ($tmp) { $tmpdoc = new DOMDocument(); - @$tmpdoc->loadHTML($tmp); - if ($tmpdoc) { + if (@$tmpdoc->loadHTML($tmp)) { $tmpxpath = new DOMXPath($tmpdoc); $source_meta = $tmpxpath->query("//meta[@name='twitter:player:stream' and contains(@content, '.mp4')]")->item(0); @@ -177,9 +176,8 @@ class Af_RedditImgur extends Plugin { if ($album_content) { $adoc = new DOMDocument(); - @$adoc->loadHTML($album_content); - if ($adoc) { + if (@$adoc->loadHTML($album_content)) { $axpath = new DOMXPath($adoc); $aentries = $axpath->query("//meta[@property='og:image']"); $urls = array(); @@ -208,6 +206,20 @@ class Af_RedditImgur extends Plugin { } } } + + // wtf is this even + if (preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) { + $img_id = $matches[1]; + + $img = $doc->createElement('img'); + $img->setAttribute("src", "https://i.gyazo.com/$img_id.jpg"); + + $br = $doc->createElement('br'); + $entry->parentNode->insertBefore($img, $entry); + $entry->parentNode->insertBefore($br, $entry); + + $found = true; + } } // remove tiny thumbnails |