Browse Source

Fix: Featured image requires absolute path #233

pull/354/head
Peter Valdemar Mørch 4 years ago
parent
commit
c64c8211e2
1 changed files with 11 additions and 3 deletions
  1. 11
    3
      layouts/partials/func/GetFeaturedImage.html

+ 11
- 3
layouts/partials/func/GetFeaturedImage.html View File

{{/* Declare a new string variable, $linkToCover */}} {{/* Declare a new string variable, $linkToCover */}}
{{ $linkToCover := "" }} {{ $linkToCover := "" }}
{{/* Declare a new string variable, $img, if this is an image resource */}}
{{ $img := "" }}
{{/* Use the value from front matter if present */}} {{/* Use the value from front matter if present */}}
{{ if .Params.featured_image }} {{ if .Params.featured_image }}
{{ $linkToCover = .Params.featured_image }}
{{ $img = (.Resources.ByType "image").GetMatch .Params.featured_image }}
{{ if not $img }}
{{ $linkToCover = .Params.featured_image }}
{{ end }}
{{/* Find the first image with 'cover' in the name in this page bundle. */}} {{/* Find the first image with 'cover' in the name in this page bundle. */}}
{{ else }} {{ else }}
{{ $img := (.Resources.ByType "image").GetMatch "*cover*" }}
{{ $img = (.Resources.ByType "image").GetMatch "*cover*" }}
{{ end }}
{{ if not $linkToCover }}
{{ with $img }} {{ with $img }}
{{ $linkToCover = .Permalink }} {{ $linkToCover = .Permalink }}
{{ end }} {{ end }}

Loading…
Cancel
Save