サマリ | YouTubeの動画再生プラグイン |
---|---|
リビジョン | 1.0 |
対応バージョン | 1.5.3 |
投稿者 | K |
投稿日 | 2020-08-08 (土) 18:40:12 |
自作プラグイン/youtube.inc.phpの最新バージョン(iFrame)
#youtube(動画ID(+パラメータ),[横],[高さ])
#youtube(1234ABCD,640,360) #youtube(1234ABCD?autoplay=1)
「plugin/youtube.inc.php」にソースコードを保存するかダウンロードします。
http://pkom.ml/youtube.inc.php
<?php function plugin_youtube_convert() { if (func_num_args() < 1) return "使い方:#youtube([VideoID],[横],[高さ])"; $args = func_get_args(); $id = trim($args[0]); $width = trim($args[1])."px"; $height = trim($args[2])."px"; if ($width == "px") $width = "100%"; if ($height == "px") $height = "0"; $str = <<<EOD <div style="width: 100%; max-width: 560px;"> <div style="position: relative; padding-bottom: 56.25%; height: $height; width: $width;"> <iframe style="position: absolute; width: 100%; height: 100%; left: 0; right: 0; top: 0; bottom: 0;" width="1280" height="720" src="https://www.youtube.com/embed/$id" frameborder="0" allowfullscreen></iframe> </div> </div> EOD; return $str; } function plugin_youtube_inline() { $args = func_get_args(); return call_user_func_array('plugin_youtube_convert', $args); } ?>