Template:YouTube
| This template uses Lua: |
| This template uses TemplateStyles |
This template embeds a YouTube video into an image thumbnail, allowing it to blend seamlessly into a wiki page.
{{YouTube|dQw4w9WgXcQ|Example caption}}
Note: An earlier version of this template required directly using <youtube>...</youtube> tags within the {{{1}}} parameter. This is now deprecated, and will not work anymore.
Usage
The {{{1}}} parameter must be a YouTube video ID. For example, within this URL https://www.youtube.com/watch?v=dQw4w9WgXcQ, the part after v= would be the ID: dQw4w9WgXcQ.
{{YouTube|i9_e0rRvyz8|The Doobie Brothers - Takin' It To The Streets (1977)}}
The above syntax will produce the video you see on the right (on desktop).
Positioning
By default, the embedded YouTube thumbnail will float to the right, but you can also set it to float left or center like so:
{{YouTube|9gbQVj4MR3M|left|Michael McDonald - I Keep Forgettin' (Every Time You're Near)}}
The above syntax will produce the video you see on the left (on desktop).
Sizing
You can change the width of the embedded video by using the {{{width}}} parameter. By default, the width is 320px, and the height is 180px, giving you a 16:9 aspect ratio. If you change the width, this aspect ratio will be retained unless you also specify a {{{height}}} parameter.
{{YouTube|tM_7ZinEDKI|center|[[YouTube|AAAAAAA]] AA A AAAAAAA AAAA AA [[AAAAAAAAA!|AAAAAAAAA]]...|width=450px}}
The above syntax will produce the video you see below.
On mobile, the embedded video will automatically be rescaled to 320px, regardless of what you specify.
All parameters
You can also call the parameters by name.
id– the YouTube video ID, you can also directly setidto be the whole YouTube video URL, but this is strongly discouraged. Note: If you use this parameter, you must also directly call the other parameters likefloatorcaptionby name.float– determines how the YouTube thumbnail will be positioned, can be set toleft,rightorcenter.caption– the caption for the YouTube thumbnailwidth– defaults to 320px, if specified, the height will automatically scale to keep a 16:9 aspect ratio.height- defaults to 180px, if specified withoutwidth, the width will stay at 320px, so you must call bothwidthandheightto fully control the size of the embedded video.
Credit
Leverage, Jean Valjean and Ben DeRoy for pioneering the idea of putting YouTube embeds into wiki thumbnails