summaryrefslogtreecommitdiff
path: root/plugins/af_youtube_embed
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2015-04-21 14:07:20 +0300
committerAndrew Dolgov <[email protected]>2015-04-21 14:07:20 +0300
commit945346cbffe266beb48e930af859879821fb8ad6 (patch)
treee68a23907881c47b0abc76397fbbe8aced04bb77 /plugins/af_youtube_embed
parente55a5ec601eb1e5df52d9299327ad63a621889ba (diff)
add HOOK_RENDER_ENCLOSURE & af_youtube_embed plugin
Diffstat (limited to 'plugins/af_youtube_embed')
-rw-r--r--plugins/af_youtube_embed/init.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/af_youtube_embed/init.php b/plugins/af_youtube_embed/init.php
new file mode 100644
index 000000000..782011340
--- /dev/null
+++ b/plugins/af_youtube_embed/init.php
@@ -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;
+ }
+
+}
+?>