Skip to content

Commit

Permalink
Allow loading cover from assets folder (adityatelange#1187)
Browse files Browse the repository at this point in the history
By default, the cover is loaded from the page resources folder (same folder).
If the image is not found, the (global) assets folder is searched as well. If found, the same processing is done.
Otherwise, the fallback remains with linking to the image directly.
  • Loading branch information
timonback authored Apr 28, 2023
1 parent f578331 commit e6606d1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion layouts/partials/cover.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<figure class="entry-cover">
{{- $responsiveImages := (.Params.cover.responsiveImages | default site.Params.cover.responsiveImages) | default true }}
{{- $addLink := (and site.Params.cover.linkFullImages (not $.IsHome)) }}
{{- $cover := (.Resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
{{- $pageBundleCover := (.Resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
{{- $globalResourcesCover := (resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
{{- $cover := (or $pageBundleCover $globalResourcesCover)}}
{{- if $cover -}}{{/* i.e it is present in page bundle */}}
{{- if $addLink }}<a href="{{ (path.Join .RelPermalink .Params.cover.image) | absURL }}" target="_blank"
rel="noopener noreferrer">{{ end -}}
Expand Down

0 comments on commit e6606d1

Please sign in to comment.