blob: 05d68313871435861608b03bc2ea34836364cf12 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<?php
class Af_GoodShowSir extends Plugin {
private $host;
function about() {
return array(1.0,
"Fix image url in goodshowsir.co.uk RSS feed",
"fox");
}
function init($host) {
$this->host = $host;
$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
}
function hook_article_filter($article) {
$doc = new DOMDocument();
$found = false;
if (!empty($article["content"]) && @$doc->loadHTML($article["content"])) {
$xpath = new DOMXpath($doc);
$images = $xpath->query('(//img[contains(@src, \'goodshowsir.co.uk\')])');
foreach ($images as $img) {
$src = $img->getAttribute("src");
$tmp = trim($src);
$tmp = str_replace("%20", "", $tmp);
if ($tmp != $src) {
$img->setAttribute("src", $tmp);
$found = true;
}
}
}
if ($found) {
$article["content"] = $doc->saveXML();
}
return $article;
}
function api_version() {
return 2;
}
}
?>
|