|
6 | 6 | @param {string} [class] The class attribute of the wrapping div element. When specified, removes the style attributes from the iframe element and its wrapping div element. |
7 | 7 | @param {bool} [controls=true] Whether to display the video controls. |
8 | 8 | @param {int} [end] The time, measured in seconds from the start of the video, when the player should stop playing the video. |
9 | | -@param {string} [id] The video id. Optional if the id is provided as first positional argument. |
| 9 | +@param {string} [id] The video id. Optional if the id is the first and only positional argument. |
10 | 10 | @param {string} [loading=eager] The loading attribute of the iframe element. |
11 | 11 | @param {bool} [loop=false] Whether to indefinitely repeat the video. Ignores the start and end arguments after the first play. |
12 | 12 | @param {bool} [mute=false] Whether to mute the video. Always true when autoplay is true. |
|
41 | 41 |
|
42 | 42 | {{- /* Get arguments. */}} |
43 | 43 | {{- if in (slice "true" true 1) ($.Get "allowFullScreen") }} |
44 | | - {{- $iframeAllowList = printf "%s; fullscreen" $iframeAllowList }} |
| 44 | + {{- $allowFullScreen = true }} |
| 45 | + {{- else if in (slice "false" false 0) ($.Get "allowFullScreen") }} |
| 46 | + {{- $allowFullScreen = false }} |
45 | 47 | {{- end }} |
46 | | - {{- if in (slice "false" false 0) ($.Get "autoplay") }} |
47 | | - {{- $autoplay = 0 }} |
48 | | - {{- else if in (slice "true" true 1) ($.Get "autoplay") }} |
| 48 | + {{- if in (slice "true" true 1) ($.Get "autoplay") }} |
49 | 49 | {{- $autoplay = 1 }} |
| 50 | + {{- else if in (slice "false" false 0) ($.Get "autoplay") }} |
| 51 | + {{- $autoplay = 0 }} |
50 | 52 | {{- end }} |
51 | | - {{- if in (slice "false" false 0) ($.Get "controls") }} |
52 | | - {{- $controls = 0 }} |
53 | | - {{- else if in (slice "true" true 1) ($.Get "controls") }} |
| 53 | + {{- if in (slice "true" true 1) ($.Get "controls") }} |
54 | 54 | {{- $controls = 1 }} |
| 55 | + {{- else if in (slice "false" false 0) ($.Get "controls") }} |
| 56 | + {{- $controls = 0 }} |
55 | 57 | {{- end }} |
56 | | - {{- if in (slice "false" false 0) ($.Get "loop") }} |
57 | | - {{- $loop = 0 }} |
58 | | - {{- else if in (slice "true" true 1) ($.Get "loop") }} |
| 58 | + {{- if in (slice "true" true 1) ($.Get "loop") }} |
59 | 59 | {{- $loop = 1 }} |
| 60 | + {{- else if in (slice "false" false 0) ($.Get "loop") }} |
| 61 | + {{- $loop = 0 }} |
60 | 62 | {{- end }} |
61 | | - {{- if in (slice "false" false 0) ($.Get "mute") }} |
62 | | - {{- $mute = 0 }} |
63 | | - {{- else if or (in (slice "true" true 1) ($.Get "mute")) $autoplay }} |
| 63 | + {{- if or (in (slice "true" true 1) ($.Get "mute")) $autoplay }} |
64 | 64 | {{- $mute = 1 }} |
| 65 | + {{- else if in (slice "false" false 0) ($.Get "mute") }} |
| 66 | + {{- $mute = 0 }} |
65 | 67 | {{- end }} |
66 | 68 | {{- $class := or ($.Get "class") $class }} |
67 | 69 | {{- $end := or ($.Get "end") $end }} |
68 | 70 | {{- $loading := or ($.Get "loading") $loading }} |
69 | 71 | {{- $start := or ($.Get "start") $start }} |
70 | 72 | {{- $title := or ($.Get "title") $title }} |
71 | 73 |
|
| 74 | + {{- /* Adjust iframeAllowList. */}} |
| 75 | + {{- if $allowFullScreen }} |
| 76 | + {{- $iframeAllowList = printf "%s; fullscreen" $iframeAllowList }} |
| 77 | + {{- end }} |
| 78 | + |
72 | 79 | {{- /* Define src attribute. */}} |
73 | 80 | {{- $host := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" }} |
74 | 81 | {{- $src := printf "https://%s/embed/%s" $host $id }} |
|
0 commit comments