Files
FixIt/layouts/partials/function/get-remote-image.html
T
2023-11-02 17:37:24 +08:00

18 lines
605 B
HTML

{{- /* cache remote image locally */ -}}
{{- $resource := 0 -}}
{{- $suffixList := slice ".jpeg" ".jpg" ".png" ".gif" ".bmp" ".tif" ".tiff" ".webp" ".avif" ".svg" -}}
{{- $suffixValid := (dict "Path" . "Suffixes" $suffixList | partial "function/suffix-validation.html") -}}
{{- if $suffixValid -}}
{{- with $remoteResource := resources.GetRemote . -}}
{{- with .Err -}}
{{- warnf "%s" . -}}
{{ else }}
{{- if eq $remoteResource.ResourceType "image" -}}
{{- $resource = $remoteResource -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- return $resource -}}