Skip to content

Commit 628bb9a

Browse files
authored
feat: use images.AutoOrient in helper/image (#1294)
* feat: use images.AutoOrient in `helper/image` closes #1292 * fix: check if IsImageResourceProcessable before using filter * remove local field * feat: add configurable image auto-orientation via a new `autoOrient` parameter in site configuration
1 parent 11aa9e3 commit 628bb9a

15 files changed

Lines changed: 28 additions & 15 deletions

File tree

config/_default/params.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ SortBy = "default"
7676
default = "auto"
7777

7878
[imageProcessing]
79+
autoOrient = false
80+
7981
[imageProcessing.content]
8082
widths = [800, 1600, 2400]
8183
enabled = true

layouts/_markup/render-image.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- $image := partial "helper/image" (dict "Resources" .Page.Resources "Image" .Destination) -}}
1+
{{- $image := partial "helper/image" (dict "Resources" .Page.Resources "Image" .Destination "Context" .Page) -}}
22
{{- $alt := .PlainText | safeHTML -}}
33
{{- $title := .Title | markdownify -}}
44

layouts/_partials/article-list/compact.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h2 class="article-title">
2323
{{- end -}}
2424
</div>
2525

26-
{{- $image := partial "helper/image" (dict "Image" .Params.image "Resources" .Resources) -}}
26+
{{- $image := partial "helper/image" (dict "Image" .Params.image "Resources" .Resources "Context" .) -}}
2727
{{ if $image }}
2828
<div class="article-image">
2929
{{ partial "helper/thumbnail-image" (dict
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{ $image := partial "helper/image" (dict "Image" .Params.image "Resources" .Resources) }}
1+
{{ $image := partial "helper/image" (dict "Image" .Params.image "Resources" .Resources "Context" .) }}
22
<article class="{{ if $image }}has-image{{ end }}">
33
{{ partial "article/components/header" (dict "Page" . "IsList" true) }}
44
</article>

layouts/_partials/article-list/tile.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{ $image := partial "helper/image" (dict "Image" .context.Params.image "Resources" .context.Resources) }}
1+
{{ $image := partial "helper/image" (dict "Image" .context.Params.image "Resources" .context.Resources "Context" .context) }}
22
<article class="{{ if $image }}has-image{{ end }}">
33
<a href="{{ .context.RelPermalink }}">
44
{{ if $image }}

layouts/_partials/article/components/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{- $IsList := .IsList -}}
22
{{- $Page := .Page -}}
33
<header class="article-header">
4-
{{- $image := partial "helper/image" (dict "Image" $Page.Params.image "Resources" $Page.Resources) -}}
4+
{{- $image := partial "helper/image" (dict "Image" $Page.Params.image "Resources" $Page.Resources "Context" $Page) -}}
55
{{ if $image }}
66
<div class="article-image">
77
<a href="{{ $Page.RelPermalink }}">

layouts/_partials/article/components/links.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h2 class="article-title">
1515
</footer>
1616
</div>
1717

18-
{{- $image := partial "helper/image" (dict "Image" $link.image "Resources" $.Resources) -}}
18+
{{- $image := partial "helper/image" (dict "Image" $link.image "Resources" $.Resources "Context" .) -}}
1919
{{- with $image -}}
2020
<div class="article-image">
2121
{{ partial "helper/thumbnail-image" (dict

layouts/_partials/head/head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}">
2424
{{- end -}}
2525

26-
{{- $favicon := partial "helper/image" (dict "Image" .Site.Params.favicon "Resources" resources) -}}
26+
{{- $favicon := partial "helper/image" (dict "Image" .Site.Params.favicon "Resources" resources "Context" .) -}}
2727
{{ with $favicon }}
2828
<link rel="shortcut icon" href="{{ .Permalink }}" />
2929
{{ end }}

layouts/_partials/head/opengraph/provider/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
{{- end -}}
3838
{{- end -}}
3939

40-
{{ $image := partial "helper/image" (dict "Image" .Params.image "Resources" .Resources) }}
40+
{{ $image := partial "helper/image" (dict "Image" .Params.image "Resources" .Resources "Context" .) }}
4141
{{- if $image -}}
4242
<meta property='og:image' content='{{ absURL $image.permalink }}' />
4343
{{- end -}}

layouts/_partials/head/opengraph/provider/twitter.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<meta name="twitter:title" {{ printf "content=%q" $title | safeHTMLAttr }}>
1010
<meta name="twitter:description" {{ printf "content=%q" $description | safeHTMLAttr }}>
1111

12-
{{- $image := partial "helper/image" (dict "Image" .Params.image "Resources" .Resources) -}}
12+
{{- $image := partial "helper/image" (dict "Image" .Params.image "Resources" .Resources "Context" .) -}}
1313
{{- if $image -}}
1414
<meta name="twitter:card" content="{{ .Site.Params.opengraph.twitter.card }}">
1515
<meta name="twitter:image" content='{{ absURL $image.permalink }}' />

0 commit comments

Comments
 (0)