}
function hook_article_filter($article) {
- $owner_uid = $article["owner_uid"];
-
- $force = false;
if (strpos($article["link"], "reddit.com/r/") !== FALSE) {
- if (strpos($article["plugin_data"], "redditimgur,$owner_uid:") === FALSE || $force) {
$doc = new DOMDocument();
@$doc->loadHTML($article["content"]);
$aentries = $axpath->query('(//img[@src])');
foreach ($aentries as $aentry) {
- if (preg_match("/^http:\/\/i.imgur.com\/$token\./", $aentry->getAttribute("src"))) {
+ if (preg_match("/\/\/i.imgur.com\/$token\./", $aentry->getAttribute("src"))) {
$img = $doc->createElement('img');
$img->setAttribute("src", $aentry->getAttribute("src"));
}
// linked albums, ffs
- if (preg_match("/^http:\/\/imgur.com\/a\/[^\.]+$/", $entry->getAttribute("href"), $matches)) {
+ if (preg_match("/^http:\/\/imgur.com\/(a|album)\/[^\.]+$/", $entry->getAttribute("href"), $matches)) {
$album_content = fetch_file_contents($entry->getAttribute("href"),
false, false, false, false, 10);
if ($node && $found) {
$article["content"] = $doc->saveXML($node);
- if (!$force) $article["plugin_data"] = "redditimgur,$owner_uid:" . $article["plugin_data"];
}
}
- } else if (isset($article["stored"]["content"])) {
- $article["content"] = $article["stored"]["content"];
- }
}
return $article;