1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 20:55:55 +00:00
Files
tt-rss/plugins/af_youtube_embed/init.php
2021-05-07 07:37:27 +03:00

45 lines
968 B
PHP

<?php
class Af_Youtube_Embed extends Plugin {
private $host;
function about() {
return array(null,
"Embed videos in Youtube RSS feeds (and whitelist Youtube iframes)",
"fox");
}
function init($host) {
$this->host = $host;
$host->add_hook($host::HOOK_RENDER_ENCLOSURE, $this);
$host->add_hook($host::HOOK_IFRAME_WHITELISTED, $this);
}
function hook_iframe_whitelisted($src) {
return in_array($src, ["www.youtube.com", "youtube.com",
"www.youtube-nocookie.com", "youtube-nocookie.com",
"youtu.be"]);
}
function hook_render_enclosure($entry, $hide_images) {
$url = $entry["content_url"];
if ($vid_id = UrlHelper::url_to_youtube_vid($url)) {
return "<div class='embed-responsive'>
<iframe class='youtube-player'
type='text/html' width='640' height='385'
src=\"https://www.youtube.com/embed/$vid_id\"
allowfullscreen frameborder='0'></iframe>
</div>";
}
}
function api_version() {
return 2;
}
}