Template:YouTube/doc
| This is a documentation subpage for Template:YouTube. It contains usage information, categories, and other content that is not part of the original template page. |
| 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 supplying the width in px. You can also use the {{{width}}} parameter.
{{YouTube|tM_7ZinEDKI|right|200px|[[YouTube|AAAAAAA]] AA A AAAAAAA AAAA AA [[AAAAAAAAA!|AAAAAAAAA]]...}}
The above syntax will produce the video you see on the right (on desktop)
On mobile, the embedded video will be automatically resized to 330px, regardless of what you specify.
Aspect ratio
By default, setting the width will keep the height at a aspect ratio. To customize the aspect ratio of a video, you must supply a named {{{height}}} parameter. You can either add or omit the "px" part of a size, like 300px or 300
{{YouTube|D_P-v1BVQn8|width=400|height=300|Gilbert O'Sullivan - Alone Again (Naturally)}}
The above syntax will produce the video you see below.
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 not recommended. Remember, if usingidwith unnamed parameters, it must come first!float– determines how the YouTube thumbnail will be positioned, can be set toleft,rightorcenter.caption– the caption for the YouTube thumbnailwidth– defaults to 330px, if specified, the height will automatically scale to keep a 16:9 aspect ratio.height- defaults to 186px, if specified withoutwidth, the width will stay at 330px, 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