summaryrefslogtreecommitdiff
path: root/layouts/shortcodes/youtube.html
blob: c29eed1c3a3e527626682f9654300ebeef27a134 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{{- $id := .Get 0 }}
{{- $title := .Get 1 }}
{{- $path := printf "ytcovers/%s.jpg" $id}}
{{- $img := resources.Get $path }}
{{- $img1x := $img.Resize "x300 webp q90" }}
{{- $img2x := $img.Resize "x600 webp q90" }}

<center>
  <a href="https://www.youtube.com/watch?v={{$id}}" target="_blank">
    <img 
      class="center"
      src="{{ $img1x.Permalink }}" 
      srcset="
        {{ $img1x.RelPermalink }} 1x,
        {{ $img2x.RelPermalink }} 2x,
      "
      width="{{ $img1x.Width }}" 
      height="{{ $img1x.Height }}"
      alt="{{$title}} on Youtube" 
      width="{{$img.Width}}" 
      height="{{$img.Height}}"
    />
  </a>
</center>