| 1 | {{/* |
| 2 | * The video shortcode: |
| 3 | * All arguments are optional, except for src which is where you define your video file |
| 4 | * This shortcode supports only webm video files. |
| 5 | * Args: |
| 6 | * class: [string] The class(es) to give to the video block. |
| 7 | * width: [int] The width of the video |
| 8 | * height: [int] The height of the video |
| 9 | * autoplay: [bool] true or false for autoplay - defaults to false |
| 10 | * loop: [bool] true or false for loop - defaults to false |
| 11 | * mute: [bool] true or false for mute - defaults to false |
| 12 | * |
| 13 | * Usage: |
| 14 | * {{< video src="my-awesome-video.mp4" width=600 height=600 autoplay=true loop=true mute=true class="some class" >}} |
| 15 | * |
| 16 | * Output: |
| 17 | * <video class="some class" controls preload="auto" width="600" height="600" autoplay loop muted> |
| 18 | <source src="my-awesome-video.mp4" type="video/webm"> |
| 19 | * </video> |
| 20 | * |
| 21 | */}} |
| 22 | |
| 23 | {{ $ext := (.Get "src") | path.Ext }} |
| 24 | {{ $filetype := slicestr $ext 1}} |
| 25 | |
| 26 | <video{{ with .Get "class" }} class="{{ . }}"{{ end }} |
| 27 | controls |
| 28 | preload="auto" |
| 29 | {{ with .Get "width" }}width="{{.}}"{{ end }} |
| 30 | {{ with .Get "height" }}height="{{.}}"{{ end }} |
| 31 | {{ if eq (.Get "autoplay") "true" }}autoplay {{ end }} |
| 32 | {{ if eq (.Get "loop") "true" }}loop {{ end }} |
| 33 | {{ if eq (.Get "muted") "true" }}muted {{ end }} |
| 34 | playsinline > |
| 35 | <source src="{{ ( .Get "src" ) }}" type="video/{{ $filetype }}"> |
| 36 | </video> |