fix: skip inaccessible images to avoid build failure (#1301)

* skip inaccessible images to avoid build failure

* undo changes to $result and $local

* fix: initialize $resource as a dictionary instead of an empty string

* feat: add external image processing timeout configuration

---------

Co-authored-by: Jimmy Cai <jimmy@cai.im>
This commit is contained in:
lijin
2026-03-08 13:18:21 +01:00
committed by GitHub
co-authored by Jimmy Cai
parent f13c478718
commit 0c941ebb04
2 changed files with 12 additions and 4 deletions
+9 -4
View File
@@ -14,7 +14,12 @@
{{ if .Image }}
{{ $url := urls.Parse .Image }}
{{ $permalink := .Image }}
{{ $resource := "" }}
{{ $resource := dict
"Resource" nil
"Permalink" $permalink
"Height" nil
"Width" nil
}}
{{ $local := true }}
{{ if not (in (slice "https" "http") $url.Scheme) }}
@@ -22,14 +27,14 @@
{{ $resource = .Resources.Get (printf "%s" (.Image | safeURL)) }}
{{ else }}
{{/* Remote image */}}
{{ with try (resources.GetRemote $url) }}
{{ with try (resources.GetRemote $url (dict "timeout" .Context.Site.Params.imageProcessing.external.timeout)) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ warnf "Failed to fetch remote resource %q: %s" $url . }}
{{ else with .Value }}
{{ $resource = . }}
{{ $local = false }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ warnf "Unable to get remote resource %q" $url }}
{{ end }}
{{ end }}
{{ end }}