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

<figure>
  <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" 
      >
  </a>
</figure>