项目作者: rimelek

项目描述 :
BB Code interpreter for youtube videos
高级语言: PHP
项目地址: git://github.com/rimelek/ybb.git
创建时间: 2017-07-16T20:24:28Z
项目社区:https://github.com/rimelek/ybb

开源协议:MIT License

下载


README

Description

This is just a simple function convert youtube video links or video IDs to the video embed code using BB codes.
You can pass arguments to the BB code or you can disable them.

Arguments

  • nocookie: Default: “off”. If it is “on” youtube-nocookie.com will be used as domain.
  • controls: Default: “on”. Whether you want to show control buttons or not.
  • suggestions: Default: “on”. You can turn suggestions after the video on or off.
  • showinfo: Default: “on”. In case of “off” the title of the video and other information will be hidden.
  • width: Default: 560. Width in pixels
  • height: Default: 315. Height in pixels

You can completely omit the value if it is “on”. “nocookie” means the same as “nocookie=on”

Examples

BB codes

  1. [youtube showinfo=off]https://www.youtube.com/watch?v=tH2TvzgFCU0[/youtube]
  2. [youtube]https://youtube.com/watch?v=tH2TvzgFCU0[/youtube]
  3. [youtube]http://www.youtube.com/watch?v=tH2TvzgFCU0[/youtube]
  4. [youtube]//www.youtube.com/watch?v=tH2TvzgFCU0[/youtube]
  5. [youtube]https://youtu.be/tH2TvzgFCU0[/youtube]
  6. [youtube]http://youtu.be/tH2TvzgFCU0[/youtube]
  7. [youtube]//youtu.be/tH2TvzgFCU0[/youtube]
  8. [youtube suggestions=off]tH2TvzgFCU0[/youtube]
  9. [youtube width=350 height=300 nocookie controls=off]tH2TvzgFCU0[/youtube]

Usage of the function

  1. <?php
  2. use Rimelek\YBB;
  3. $text = '... Here is your text containing bb codes like: [youtube width=350 height=300 nocookie controls=off]tH2TvzgFCU0[/youtube] ... ';
  4. echo YBB\ybb($text);
  5. echo YBB\ybb($text, ['nocookie' => 'on']);
  6. echo YBB\ybb($text, ['nocookie' => 'on'], ['width', 'height']);

Instead of “on”, you can always write “yes”, “1”, or “true”
Instead of “off”, you can always write “no”, “0” or “false”

Run demo.php for a working demo.