summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-03-12 11:26:44 +0400
committerAndrew Dolgov <[email protected]>2013-03-12 11:26:44 +0400
commit35055d050b51693e2f85dcd4e6ce3ce60268d00b (patch)
tree321e4ff81d2a25e5064683df0bc32f04faf9acf6 /plugins
parentce7d5e87659290dec20cc8d673d9a3559c83c628 (diff)
af_redditimgur: support albums
Diffstat (limited to 'plugins')
-rw-r--r--plugins/af_redditimgur/init.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index 53cb875c8..5e863108d 100644
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -45,7 +45,7 @@ class Af_RedditImgur extends Plugin {
// links to imgur pages
$matches = array();
- if (preg_match("/^http:\/\/imgur.com\/([^\.]+$)/", $entry->getAttribute("href"), $matches)) {
+ if (preg_match("/^http:\/\/imgur.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) {
$token = $matches[1];
@@ -66,11 +66,37 @@ class Af_RedditImgur extends Plugin {
$img->setAttribute("src", $aentry->getAttribute("src"));
$entry->parentNode->insertBefore($img, $entry);
$found = true;
+
+ break;
}
}
}
}
}
+
+ // linked albums, ffs
+ if (preg_match("/^http:\/\/imgur.com\/a\/[^\.]+$/", $entry->getAttribute("href"), $matches)) {
+
+ $album_content = fetch_file_contents($entry->getAttribute("href"),
+ false, false, false, false, 10);
+
+ if ($album_content) {
+ $adoc = new DOMDocument();
+ @$adoc->loadHTML($album_content);
+
+ if ($adoc) {
+ $axpath = new DOMXPath($adoc);
+ $aentries = $axpath->query("//div[@class='image']//a[@href and @class='zoom']");
+
+ foreach ($aentries as $aentry) {
+ $img = $doc->createElement('img');
+ $img->setAttribute("src", $aentry->getAttribute("href"));
+ $entry->parentNode->insertBefore($img, $entry);
+ $found = true;
+ }
+ }
+ }
+ }
}
// remove tiny thumbnails