forked from laurens/fediversity_website
		
	
		
			
				
	
	
		
			34 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
{{ if .link }}<a href="{{ .link }}">{{ end }}
 | 
						|
<figure>
 | 
						|
  <picture>
 | 
						|
    {{ $isJPG := eq (path.Ext .image) ".jpg" }}
 | 
						|
    {{ $isPNG := eq (path.Ext .image) ".png" }}
 | 
						|
 | 
						|
    {{ if ($isJPG) -}}
 | 
						|
      {{ $webpPath:= replace .image ".jpg" ".webp" }}
 | 
						|
      {{ $webpPathStatic:= printf "static/%s" $webpPath }}
 | 
						|
 | 
						|
      {{ if (fileExists $webpPathStatic) -}}
 | 
						|
        <source srcset="{{ $webpPath | safeURL }}" type="image/webp">
 | 
						|
      {{- end }}
 | 
						|
    {{- end }}
 | 
						|
 | 
						|
    {{ if ($isPNG) -}}
 | 
						|
      {{ $webpPath:= replace .image ".png" ".webp" }}
 | 
						|
      {{ $webpPathStatic:= printf "static/%s" $webpPath }}
 | 
						|
 | 
						|
      {{ if (fileExists $webpPathStatic) -}}
 | 
						|
        <source srcset="{{ $webpPath | safeURL }}" type="image/webp">
 | 
						|
      {{- end }}
 | 
						|
    {{- end }}
 | 
						|
    {{ $img := imageConfig (add "/static" (.image | safeURL)) }}
 | 
						|
 | 
						|
      <img src="{{ .image | safeURL }}" alt="{{ .alt }}" loading="lazy" decoding="async" width="{{ $img.Width }}" height="{{ $img.Height }}">
 | 
						|
  </picture>
 | 
						|
  {{ if .figcaption }}
 | 
						|
    <figcaption>
 | 
						|
      <small><strong>{{ .figcaption }}</strong></small>
 | 
						|
    </figcaption>
 | 
						|
  {{ end }}
 | 
						|
</figure>
 | 
						|
{{ if .link }}</a>{{ end }}
 |