Files
FixIt/layouts/_partials/function/get-remote-image.html
T
Cell 1bb21fcbd1 fix: improve warning messages for remote image retrieval failures
You can suppress the warning by adding the following to your site configuration:
ignoreLogs = ['warning-remote-image']
2025-12-22 16:38:39 +08:00

20 lines
685 B
HTML

{{- /* cache remote image locally */ -}}
{{- $resource := 0 -}}
{{- $isRemote := urls.Parse .Src | partial "function/is-url-remote.html" -}}
{{- if $isRemote -}}
{{- with try (resources.GetRemote .Src) -}}
{{- with .Err -}}
{{- warnidf "warning-remote-image" "%s" . -}}
{{- else with .Value -}}
{{- if .ResourceType | eq "image" -}}
{{- /* placed remote image in public/images/remote/ */ -}}
{{- $resource = . | resources.Copy (add "/images/remote/" .Name) -}}
{{- end -}}
{{- else -}}
{{- warnidf "warning-remote-image" "Failed to get remote image %q" $.Src -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- return $resource -}}