Skip to content

Commit 056ff31

Browse files
committedJul 23, 2023
Fix thumbnail
1 parent bd5cd5c commit 056ff31

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed
 

‎layouts/partials/components/article-list.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h2>
1010
</h2>
1111
</header>
1212
{{ $link := .RelPermalink }}
13-
{{ with partial "functions/feature-image" . }}
13+
{{ with partial "functions/feature-image" (dict "context" . "fallbackGlobal" false "preferOriginal" false) }}
1414
<a href="{{ $link }}" class="thumbnail-link">
1515
<img class="thumbnail" src="{{ . }}">
1616
</a>

‎layouts/partials/functions/feature-image.html

+21-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1+
{{ $fallbackGlobal := .fallbackGlobal }}
2+
{{ $preferOriginal := .preferOriginal }}
13
{{ $image := false }}
2-
{{ with .Params.images }}
3-
{{ $image = index . 0 | relURL }}
4-
{{ else }}
5-
{{ $images := .Resources.ByType "image" }}
6-
{{ $featured := $images.GetMatch "*feature*" }}
7-
{{ $featured := cond (ne $featured nil) $featured ($images.GetMatch "{*cover*,*thumbnail*}") }}
8-
{{ with $featured }}
9-
{{ if gt $featured.Width 720 }}
10-
{{ $featured = $featured.Resize "720x" }}
11-
{{ end }}
12-
{{ $image = $featured.RelPermalink }}
4+
{{ with .context }}
5+
{{ with .Params.images }}
6+
{{ $image = index . 0 | relURL }}
137
{{ else }}
14-
{{ with .Site.Params.images }}
15-
{{ $image = index . 0 | relURL }}
8+
{{ $images := .Resources.ByType "image" }}
9+
{{ $featured := $images.GetMatch "*feature*" }}
10+
{{ $featured := cond (ne $featured nil) $featured ($images.GetMatch "{*cover*,*thumbnail*}") }}
11+
{{ with $featured }}
12+
{{ if not $preferOriginal }}
13+
{{ if gt $featured.Width 720 }}
14+
{{ $featured = $featured.Resize "720x" }}
15+
{{ end }}
16+
{{ end }}
17+
{{ $image = $featured.RelPermalink }}
18+
{{ else }}
19+
{{ if $fallbackGlobal }}
20+
{{ with .Site.Params.images }}
21+
{{ $image = index . 0 | relURL }}
22+
{{ end }}
23+
{{ end }}
1624
{{ end }}
1725
{{ end }}
1826
{{ end }}

‎layouts/partials/heads/ogp.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<meta name="og:description" content="{{ .Summary }}">
2222
{{ end }}
2323
<meta property="og:url" content="{{ .Permalink }}">
24-
{{ with partial "functions/feature-image" . }}
24+
{{ with partial "functions/feature-image" (dict "context" . "fallbackGlobal" true "preferOriginal" true) }}
2525
<meta property="og:image" content="{{ . | absURL }}">
2626
{{ end }}

0 commit comments

Comments
 (0)
Please sign in to comment.