24 lines
667 B
PHP
Raw Permalink Normal View History

2015-05-15 10:07:58 +02:00
<?php
class Af_Youtube_Thumbnail extends Plugin {
function about() {
2015-05-15 10:41:20 +02:00
return array(0.1,
"Add the thumbnail for Youtube videos",
"gdott9");
2015-05-15 10:07:58 +02:00
}
function init($host) {
2015-05-15 10:41:20 +02:00
$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
2015-05-15 10:07:58 +02:00
}
function hook_article_filter($article) {
2015-05-15 10:41:20 +02:00
if(strpos($article["link"], "youtube.com") !== FALSE) {
$video_id = str_replace('https://www.youtube.com/watch?v=', '', $article["link"]);
$article["content"] = '<img src="https://img.youtube.com/vi/'.$video_id.'/hqdefault.jpg" alt="'.$article["title"].'" /><br />'.$article["content"];
2015-05-15 10:41:20 +02:00
}
return $article;
2015-05-15 10:07:58 +02:00
}
function api_version() { return 2; }
}