Add thumbnail into article content

This commit is contained in:
Guillaume Dott 2015-05-15 10:41:20 +02:00
parent 21a1f54e60
commit 4ff23f52d7

View File

@ -1,12 +1,22 @@
<?php
class Af_Youtube_Thumbnail extends Plugin {
function about() {
return array(0.1,
"Add the thumbnail for Youtube videos",
"gdott9");
}
function init($host) {
$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
}
function hook_article_filter($article) {
if(strpos($article["link"], "youtube.com") !== FALSE) {
$video_id = str_replace('http://www.youtube.com/watch?v=', '', $article["link"]);
$article["content"] = '<img src="http://img.youtube.com/vi/'.$video_id.'/hqdefault.jpg" alt="'.$article["title"].'" />';
}
return $article;
}
function api_version() { return 2; }