diff --git a/config/_default/params.toml b/config/_default/params.toml index 141e813..1f844fc 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -77,6 +77,9 @@ SortBy = "default" [imageProcessing] autoOrient = false + [imageProcessing.external] + timeout = "5s" + [imageProcessing.content] widths = [800, 1600, 2400] enabled = true diff --git a/layouts/_partials/helper/image.html b/layouts/_partials/helper/image.html index 1ebc586..2ee4f39 100644 --- a/layouts/_partials/helper/image.html +++ b/layouts/_partials/helper/image.html @@ -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 }}