add HOOK_RENDER_ENCLOSURE & af_youtube_embed plugin
This commit is contained in:
parent
e55a5ec601
commit
945346cbff
|
@ -43,6 +43,7 @@ class PluginHost {
|
||||||
const HOOK_FORMAT_ENCLOSURES = 26;
|
const HOOK_FORMAT_ENCLOSURES = 26;
|
||||||
const HOOK_SUBSCRIBE_FEED = 27;
|
const HOOK_SUBSCRIBE_FEED = 27;
|
||||||
const HOOK_HEADLINES_BEFORE = 28;
|
const HOOK_HEADLINES_BEFORE = 28;
|
||||||
|
const HOOK_RENDER_ENCLOSURE = 29;
|
||||||
|
|
||||||
const KIND_ALL = 1;
|
const KIND_ALL = 1;
|
||||||
const KIND_SYSTEM = 2;
|
const KIND_SYSTEM = 2;
|
||||||
|
|
|
@ -1940,6 +1940,14 @@
|
||||||
|
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
|
|
||||||
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin)
|
||||||
|
$retval = $plugin->hook_render_enclosure($entry, $hide_images);
|
||||||
|
|
||||||
|
|
||||||
|
if ($retval) {
|
||||||
|
$rv .= $retval;
|
||||||
|
} else {
|
||||||
|
|
||||||
if (preg_match("/image/", $entry["type"]) ||
|
if (preg_match("/image/", $entry["type"]) ||
|
||||||
preg_match("/\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
|
preg_match("/\.(jpg|png|gif|bmp)/i", $entry["filename"])) {
|
||||||
|
|
||||||
|
@ -1966,6 +1974,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (count($entries_inline) > 0) {
|
if (count($entries_inline) > 0) {
|
||||||
$rv .= "<hr clear='both'/>";
|
$rv .= "<hr clear='both'/>";
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
class Af_Youtube_Embed extends Plugin {
|
||||||
|
private $host;
|
||||||
|
|
||||||
|
function about() {
|
||||||
|
return array(1.0,
|
||||||
|
"Embed videos in Youtube RSS feeds",
|
||||||
|
"fox");
|
||||||
|
}
|
||||||
|
|
||||||
|
function init($host) {
|
||||||
|
$this->host = $host;
|
||||||
|
|
||||||
|
$host->add_hook($host::HOOK_RENDER_ENCLOSURE, $this);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hook_render_enclosure($entry, $hide_images) {
|
||||||
|
|
||||||
|
$matches = array();
|
||||||
|
|
||||||
|
if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry["url"], $matches) ||
|
||||||
|
preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry["url"], $matches) ||
|
||||||
|
preg_match("/\/\/youtu.be\/([\w-]+)/", $entry["url"], $matches)) {
|
||||||
|
|
||||||
|
$vid_id = $matches[1];
|
||||||
|
|
||||||
|
return "<iframe class=\"youtube-player\"
|
||||||
|
type=\"text/html\" width=\"640\" height=\"385\"
|
||||||
|
src=\"https://www.youtube.com/embed/$vid_id\"
|
||||||
|
allowfullscreen frameborder=\"0\"></iframe>";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function api_version() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue