Files
FixIt/layouts/partials/function/get-remote-image.html
T

22 lines
697 B
HTML

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