==README for YouTube BB code add-on for miniBB==
Release date: November 2, 2006.
Latest update: November 25, 2025.
miniBB version: 3.3+
Author: Paul Puzyrev (minibb.com)

This plug-in adds possibility to embed YouTube videos in forum postings. Works like any regular BB code with the button provided. Click the button - enter YouTube URL video - post the message. Additionally, you may set the custom video size, or embed the direct Embed code YouTube provides.


==INSTALLATION==

* Copy the button image img/button_youtube.svg under /img/ folder of your forum

* Copy the contents from `bb_codes.encode_1.txt` and paste them in `bb_codes.php` -> enCodeBB function -> ABOVE the following code: `$msg=preg_replace_callback("/\[nobb\][\r\n]*(.+?)[\r\n]*\[\/nobb\]/is", 'noBBCodes', $msg);`.

* Copy the contents from `bb_codes.encode_2.txt` and paste them in `bb_codes.php` -> enCodeBB function -> ABOVE the following code: `$msg=preg_replace($pattern, $replacement, $msg);` (there could be code blocks from the other plugins located above or below).

* Copy the contents from `bb_codes.decode.txt` and paste them in `bb_codes.php` -> deCodeBB function -> ABOVE the following code: `$msg=preg_replace($pattern, $replacement, $msg);` (there could be code blocks from the other plugins located above or below).

* At the end of your language pack, lang/eng.php or related, paste the code located under lang/eng.code.txt (or from the related language snippet).

* Modify bb_plugins.php and, if you use the Preview add-on, BEFORE the code for the Preview add-on; or most likely anywhere else paste the code located under bb_plugins.code.txt. If you already have the /* Responsive videos */ code coming from another videos-embedding add-on (for example, Vimeo), you don't have to paste it. I.e. have it pasted only once for all similar add-ons.

* If you have Preview add-on installed, open templates/addon_preview.html and paste before the closing </head>:

{$responsiveMediaBlock}

* Open the templates/main_post_form.html template and paste the following in the position where other BB buttons are placed (the code for a BB-button):

{$button_youtube}

* Open templates/form.js and in the function called `insertAtCursor`, before the line which says

`//MOZILLA/NETSCAPE/OPERA support`

paste the code provided under "form_js.code.txt" - it will avoid `[youtube=null]` insertion in the message, if YouTube BB code button is cancelled.


==USAGE==

Any of the current YouTube default sharing methods should work.

You can get the links, pressing the Share button under YouTube video, then Copy the suggested link; alternatively, you can check the "Start at" box if you'd like the video to start playing at certain time. On the desktop version, you can click the mouse right button and then "Copy video URL" or "Copy video URL at current time". The link from URL bar also could be copied.

The links you get that way, should be pasted in the field which appears after clicking the "YouTube" button appearing above miniBB message form, and then transformed into a BB code in the message body.

Clicking the Embed button, you can also copy the straight code to paste (this method will provide the correct video size instead of common default), and here you can also check the "Start at" box. This code should be pasted straight into our message, skipping the "YouTube" button.

Default video size if it's not specified, is 640x360 and this could be changed in the code located under `bb_codes.encode_1.txt`.

Examples which could be pasted in the message body:

1. [youtube=https://youtu.be/kKX_yN30CMQ?si=S0OcffKngGlqH6ne] (default shared link)

2. [youtube=https://youtu.be/kKX_yN30CMQ?si=S0OcffKngGlqH6ne&t=37] (default shared link with timestamp)

3. [youtube=https://youtu.be/kKX_yN30CMQ] (the link from the mouse right-button click)

4. [youtube=https://youtu.be/kKX_yN30CMQ?t=37] (the link from the mouse right-button click with timestamp)

5. [youtube=https://www.youtube.com/watch?v=kKX_yN30CMQ] (the link copied from URL bar)

6. <iframe width="560" height="315" src="https://www.youtube.com/embed/kKX_yN30CMQ?si=fFI7Yh4xG7-wY9xT" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> (Embed code)

7. <iframe width="560" height="315" src="https://www.youtube.com/embed/kKX_yN30CMQ?si=eOXxVbhWUvVNEuvD&amp;start=37" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> (Embed code with timestamp)

After editing the message, any of the code mentioned above, will be transformed to a common BB code which looks like this:

[youtube560x315=https://youtu.be/kKX_yN30CMQ?si=fFI7Yh4xG7-wY9xT]
or
[youtube640x360=https://youtu.be/kKX_yN30CMQ]
or
[youtube560x315=https://youtu.be/kKX_yN30CMQ?si=eOXxVbhWUvVNEuvD&start=37]

i.e. video size will be transformed to the part of BB code.

==FINALLY==
Questions? Suggestions? Improvements? Post them quickly on our support forums:
https://www.minibb.com/forums/12_4286_0.html
