mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-13 02:14:21 +00:00
feat: align with .Params.image for featured/cover image
This commit is contained in:
1 parent
b46f34be28
commit
18ac0b42a8
1 file changed
+7
-18
@@ -35,26 +35,15 @@
|
||||
</div>
|
||||
|
||||
{{/* Cover image */}}
|
||||
{{ if and .Params.cover.image }}
|
||||
{{ $cover_image := partial "functions/get_featured_image.html" . }}
|
||||
{{ if $cover_image }}
|
||||
<div class="article-header">
|
||||
{{- $img := "" -}}
|
||||
{{ $alt := (.Params.cover.caption | default "") | plainify }}
|
||||
{{ $destination := .Params.cover.image }}
|
||||
{{ $is_remote := strings.HasPrefix $destination "http" }}
|
||||
{{- if not $is_remote -}}
|
||||
{{- $img = (.Page.Resources.ByType "image").GetMatch $destination -}}
|
||||
{{- if not $img -}}
|
||||
{{- $img = resources.Get (path.Join "media" $destination) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ if $img }}
|
||||
{{ $img = $img.Fit "1800x310 webp" }}
|
||||
<img src="{{$img.RelPermalink}}" width="{{$img.Width}}" height="{{$img.Height}}" class="article-banner" alt="{{$alt}}">
|
||||
{{ else }}
|
||||
<img src="{{ .Params.cover.image }}" class="article-banner" alt="{{$alt}}">
|
||||
{{ $alt := (.Params.image.caption | default "") | plainify }}
|
||||
{{ $cover_image = $cover_image.Fit "1800x310 webp" }}
|
||||
<img src="{{$cover_image.RelPermalink}}" width="{{$cover_image.Width}}" height="{{$cover_image.Height}}" class="article-banner" alt="{{$alt}}">
|
||||
{{ with (.Params.image.alt_text | default .Params.image.caption) }}
|
||||
<span class="article-header-caption">{{ . | markdownify | emojify }}</span>
|
||||
{{ end }}
|
||||
|
||||
{{ with .Params.cover.caption }}<span class="article-header-caption">{{ . | markdownify | emojify }}</span>{{ end }}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
|
||||
Reference in new issue
Block a user