Compare commits

..
Author SHA1 Message Date
JimmyandGitHub f13c478718 fix: check if resource exists before accessing .RelPermalink (#1299)
* fix: check if resource exists before accessing `.RelPermalink`

closes https://github.com/CaiJimmy/hugo-theme-stack/issues/1297

* Set default value of $result in `helper/image` to dict
2026-03-06 00:13:13 +01:00
JimmyandGitHub bde2914dec chore: Remove featuredImageField from configuration (#1298)
chore: Remove `featuredImageField` from configuration.
2026-03-05 23:56:27 +01:00
2 changed files with 9 additions and 10 deletions
+3 -4
View File
@@ -1,10 +1,9 @@
mainSections = ["post"]
featuredImageField = "image"
rssFullContent = true
mainSections = ["post"]
rssFullContent = true
# Accepted values: "default", "lastmod"
# default = see https://gohugo.io/quick-reference/glossary/#default-sort-order
# lastmod = sort by last modified date, in descending order
SortBy = "default"
SortBy = "default"
[footer]
since = 2026
+5 -5
View File
@@ -9,7 +9,7 @@
/// Height: Image height
/// Width: Image width
{{ $result := "" }}
{{ $result := dict }}
{{ if .Image }}
{{ $url := urls.Parse .Image }}
@@ -20,7 +20,6 @@
{{ if not (in (slice "https" "http") $url.Scheme) }}
{{/* Local image */}}
{{ $resource = .Resources.Get (printf "%s" (.Image | safeURL)) }}
{{ $permalink = $resource.RelPermalink }}
{{ else }}
{{/* Remote image */}}
{{ with try (resources.GetRemote $url) }}
@@ -39,9 +38,10 @@
{{ if and .Context.Site.Params.imageProcessing.autoOrient (reflect.IsImageResourceProcessable $resource) }}
{{ $filter := images.AutoOrient }}
{{ $resource = $resource | images.Filter $filter }}
{{ if $local }}
{{ $permalink = $resource.RelPermalink }}
{{ end }}
{{ end }}
{{ if $local }}
{{ $permalink = $resource.RelPermalink }}
{{ end }}
{{ if reflect.IsImageResourceWithMeta $resource }}