mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 16:31:52 +01:00
77 lines
2.3 KiB
HTML
77 lines
2.3 KiB
HTML
{{ $disableImageOptimization := site.Store.Get "disableImageOptimization" }}
|
|
|
|
{{ $useDefault := false }}
|
|
{{ $featured := "" }}
|
|
{{ $featuredURL := "" }}
|
|
{{ with .Params.featureimage }}
|
|
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
|
|
{{ if site.Params.hotlinkFeatureImage }}
|
|
{{ $featuredURL = . }}
|
|
{{ else }}
|
|
{{ $featured = resources.GetRemote . }}
|
|
{{ end }}
|
|
{{ else }}
|
|
{{ $featured = resources.Get . }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ if not (or $featured $featuredURL) }}
|
|
{{ $images := .Resources.ByType "image" }}
|
|
{{ range slice "*background*" "*feature*" "*cover*" "*thumbnail*" }}
|
|
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ if not (or $featured $featuredURL) }}
|
|
{{ $default := site.Store.Get "defaultBackgroundImage" }}
|
|
{{ if $default.url }}
|
|
{{ $featuredURL = $default.url }}
|
|
{{ $useDefault = true }}
|
|
{{ else if $default.obj }}
|
|
{{ $featured = $default.obj }}
|
|
{{ $useDefault = true }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{/* generate image URL if not hotlink */}}
|
|
{{ if not $featuredURL }}
|
|
{{ with $featured }}
|
|
{{ $featuredURL = .RelPermalink }}
|
|
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
|
|
{{ $size := site.Store.Get "backgroundImageWidth" }}
|
|
{{ $featuredURL = (.Resize $size).RelPermalink }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ $caption := "" }}
|
|
{{ if .Params.featureimagecaption }}
|
|
{{- $caption = .Params.featureimagecaption -}}
|
|
{{ end }}
|
|
|
|
{{- $alt := .Page.Title -}}
|
|
{{- with .Page.Params.alt }}{{ $alt = . }}{{ end -}}
|
|
|
|
{{ with $featuredURL }}
|
|
{{ $style := "" }}
|
|
{{ $defaultPosition := cond $useDefault site.Params.imagePosition false }}
|
|
{{ with $.Params.imagePosition | default $defaultPosition }}
|
|
{{ $style = printf "object-position: %s;" . }}
|
|
{{ end }}
|
|
<figure>
|
|
<img
|
|
src="{{ . }}"
|
|
alt="{{ $alt }}"
|
|
loading="eager"
|
|
decoding="async"
|
|
fetchpriority="high"
|
|
class="w-full rounded-lg single_hero_round nozoom"
|
|
{{ if $style }}style="{{ $style | safeCSS }}"{{ end }}>
|
|
{{ if $caption }}
|
|
<figcaption class="text-sm text-neutral-700 dark:text-neutral-400 hover:underline text-center">
|
|
{{ $caption | markdownify }}
|
|
</figcaption>
|
|
{{ end }}
|
|
</figure>
|
|
{{ end }}
|