feat: Append video description
This commit is contained in:
parent
6fb9ee7c38
commit
735917119f
31
init.php
31
init.php
@ -5,8 +5,8 @@ class YFrames extends Plugin {
|
||||
|
||||
function about() {
|
||||
return array(1.0,
|
||||
"iFrames for Youtube feeds",
|
||||
"phga");
|
||||
"iFrames for Youtube feeds",
|
||||
"phga");
|
||||
}
|
||||
|
||||
function init($host) {
|
||||
@ -22,20 +22,27 @@ class YFrames extends Plugin {
|
||||
|
||||
function hook_article_filter($article) {
|
||||
|
||||
// $debug = json_encode($article);
|
||||
// Match allowed links and extract "video ID"
|
||||
if (preg_match_all("/.*(youtube|youtu)\.(com|be)\/watch\?v=([\w\d_-]+).*/i",
|
||||
$article["link"], $matches, PREG_PATTERN_ORDER)) {
|
||||
if (preg_match_all("/.*(youtube|youtu)\.(com|be)\/watch\?v=([\w\d_-]+).*/i",
|
||||
$article["link"], $matches, PREG_PATTERN_ORDER)) {
|
||||
|
||||
if ($matches[3][0]) {
|
||||
$link = "https://www.youtube.com/embed/" . $matches[3][0];
|
||||
$attributes = "width='819' height='460' class='youtube-player' allowfullscreen";
|
||||
$yframe = "<iframe src='$link' $attributes></iframe>";
|
||||
if ($matches[3][0]) {
|
||||
$link = "https://www.youtube.com/embed/" . $matches[3][0];
|
||||
$attributes = "width='819' height='460' class='youtube-player' allowfullscreen";
|
||||
$yframe = "<iframe src='$link' $attributes></iframe>";
|
||||
|
||||
$article["content"] = $yframe;
|
||||
}
|
||||
}
|
||||
$article["content"] = $yframe;
|
||||
}
|
||||
}
|
||||
|
||||
$description = str_replace("\n", "<br/>", $article["enclosures"][0][3]);
|
||||
if (strlen($description) > 0) {
|
||||
$article["content"] .= "<br/>" . $description ;
|
||||
} else {
|
||||
$article["content"] .= "<br/>No video description available.";
|
||||
}
|
||||
|
||||
$article["content"] .= "<br/>" . $link;
|
||||
return $article;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user