Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cover.html « partials « layouts - gitlab.com/rmaguiar/hugo-theme-color-your-world.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4e741b6febf4a0b2f05dae14337563ce2ab8ff09 (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
25
26
27
28
29
30
31
32
33
34
35
{{ $file    := .Params.cover }}
{{ $altText := .Params.coverAlt }}

<!-- Image processing options -->
{{ $imageProc := (dict "highRes" (.Site.Params.imageProc.highRes | default .Site.Data.default.imageProc.highRes) "mediumRes" (.Site.Params.imageProc.mediumRes | default .Site.Data.default.imageProc.mediumRes) "lowRes" (.Site.Params.imageProc.lowRes | default .Site.Data.default.imageProc.lowRes)) }}

<!-- Default image path -->
{{ $imgPath := .Page.Param "imgPath" }}

{{ if $imgPath }}
  {{ $file = path.Join $imgPath $file }}
{{ end }}

{{ with $.Page.Resources.GetMatch $file }}
  
  {{ $mediumRes := (index $imageProc.mediumRes 0) }}

  {{ $outputSet := slice }}
  {{ $inputFile := . }}
  
  {{ range $imageProc }}
    {{ $outputSet = $outputSet | append (printf "%s %s" (($inputFile.Resize (index . 0)).RelPermalink) (index . 1)) }}
  {{ end }}

  <img
    class="cover"
    loading="lazy"
    srcset='{{ delimit $outputSet ", " }}'
    src="{{ (.Resize $mediumRes).RelPermalink }}"
    width="{{ (.Resize $mediumRes).Width }}"
    height="{{ (.Resize $mediumRes).Height }}"
    {{ with $altText }}alt="{{ . }}"{{ end }}
  />

{{ end }}