summaryrefslogtreecommitdiff
path: root/layouts/shortcodes/youtube.html
blob: 6a2409b9ebe4a6c2b4613e4da8407ca507fd6ee7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{{- $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" }}

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