Jump to content

Template:YouTube: Difference between revisions

From SOJI ELECTRONICS
[checked revision][checked revision]
Update
Update
 
(9 intermediate revisions by the same user not shown)
Line 2: Line 2:
== YouTube Embed Template ==
== YouTube Embed Template ==


Embed YouTube video easily in VisualEditor and Source Editor.
Embed YouTube video. Auto-strips query parameters from ID.


'''Usage:''' <code><nowiki>{{YouTube|id=dQw4w9WgXcQ|width=640|align=center|caption=Installation tutorial}}</nowiki></code>
'''Usage:''' <code><nowiki>{{YouTube|id=VIDEO_ID|width=640|align=center|caption=Description}}</nowiki></code>
 
'''Parameters:'''
* '''id''' (required) — YouTube video ID (the part after <code>v=</code> in URL)
* '''width''' (optional) — Player width in px, default 640
* '''align''' (optional) — left / center / right / inline, default center
* '''caption''' (optional) — Description text shown below video
 
'''Example with all params:'''
<pre>
{{YouTube
| id = dQw4w9WgXcQ
| width = 640
| align = center
| caption = Installation tutorial for LIGO MAX
}}
</pre>


{{TemplateData
{{TemplateData
|description=Embed a YouTube video. Get the video ID from URL (e.g., dQw4w9WgXcQ from youtube.com/watch?v=dQw4w9WgXcQ).
|description=Embed a YouTube video. Paste video ID (the 11 characters after v= in YouTube URL).
|params={
|params={
     "id": {
     "id": {
Line 29: Line 13:
         "type": "string",
         "type": "string",
         "required": true,
         "required": true,
         "description": "Video ID — the part after v= in YouTube URL. Example: dQw4w9WgXcQ"
         "description": "Video ID (11 chars). Query parameters auto-stripped."
     },
     },
     "width": {
     "width": {
         "label": "Width (px)",
         "label": "Width (px)",
         "type": "number",
         "type": "number",
         "default": "640",
         "default": "640"
        "description": "Player width in pixels. Height auto-calculated 16:9. Common values: 480, 640, 800"
     },
     },
     "align": {
     "align": {
Line 41: Line 24:
         "type": "string",
         "type": "string",
         "default": "center",
         "default": "center",
         "description": "Position: left, center, right, or inline"
         "description": "left / center / right"
     },
     },
     "caption": {
     "caption": {
         "label": "Caption",
         "label": "Caption",
         "type": "string",
         "type": "string",
         "required": false,
         "required": false
        "description": "Optional caption text shown below the video"
     }
     }
}
}
Line 53: Line 35:


[[Category:Templates]]
[[Category:Templates]]
<includeonly><div style="text-align:{{{align|center}}};">
</noinclude><includeonly><div class="soji-yt-embed" data-video-id="{{#explode:{{#explode:{{{id|}}}|?|0}}|&|0}}" data-width="{{{width|640}}}" data-align="{{{align|center}}}" data-caption="{{{caption|}}}"></div></includeonly>
<youtube width="{{{width|640}}}" height="{{#expr: {{{width|640}}} * 9 / 16 round 0}}">{{#explode:{{#explode:{{{id|}}}|?|0}}|&|0}}</youtube>
{{#if:{{{caption|}}}|<br><em>{{{caption}}}</em>|}}
</div></includeonly>

Latest revision as of 08:27, 25 May 2026

YouTube Embed Template

Embed YouTube video. Auto-strips query parameters from ID.

Usage: {{YouTube|id=VIDEO_ID|width=640|align=center|caption=Description}}

Template:TemplateData

SOJI Electronics