add HOOK_ARTICLE_IMAGE for Article::get_article_image()
This commit is contained in:
parent
ffb842f752
commit
9d852e052c
|
@ -828,6 +828,11 @@ class Article extends Handler_Protected {
|
|||
$article_image = "";
|
||||
$article_stream = "";
|
||||
|
||||
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_IMAGE) as $p) {
|
||||
list ($article_image, $article_stream) = $p->hook_article_image($enclosures, $content, $site_url);
|
||||
}
|
||||
|
||||
if (!$article_image && !$article_stream) {
|
||||
$tmpdoc = new DOMDocument();
|
||||
|
||||
if (@$tmpdoc->loadHTML('<?xml encoding="UTF-8">' . mb_substr($content, 0, 131070))) {
|
||||
|
@ -861,26 +866,27 @@ class Article extends Handler_Protected {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$article_image)
|
||||
foreach ($enclosures as $enc) {
|
||||
if (strpos($enc["content_type"], "image/") !== FALSE) {
|
||||
$article_image = $enc["content_url"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($article_image)
|
||||
$article_image = rewrite_relative_url($site_url, $article_image);
|
||||
|
||||
if ($article_stream)
|
||||
$article_stream = rewrite_relative_url($site_url, $article_stream);
|
||||
|
||||
if (!$article_image)
|
||||
foreach ($enclosures as $enc) {
|
||||
if (strpos($enc["content_type"], "image/") !== FALSE) {
|
||||
$article_image = rewrite_relative_url($site_url, $enc["content_url"]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$cache = new DiskCache("images");
|
||||
|
||||
if ($cache->exists(sha1($article_image)))
|
||||
if ($article_image && $cache->exists(sha1($article_image)))
|
||||
$article_image = $cache->getUrl(sha1($article_image));
|
||||
|
||||
if ($cache->exists(sha1($article_stream)))
|
||||
if ($article_stream && $cache->exists(sha1($article_stream)))
|
||||
$article_stream = $cache->getUrl(sha1($article_stream));
|
||||
|
||||
return [$article_image, $article_stream];
|
||||
|
|
|
@ -59,6 +59,7 @@ class PluginHost {
|
|||
const HOOK_SEND_MAIL = 39;
|
||||
const HOOK_FILTER_TRIGGERED = 40;
|
||||
const HOOK_GET_FULL_TEXT = 41;
|
||||
const HOOK_ARTICLE_IMAGE = 42;
|
||||
|
||||
const KIND_ALL = 1;
|
||||
const KIND_SYSTEM = 2;
|
||||
|
|
Loading…
Reference in New Issue