mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
22 lines
697 B
HTML
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 -}}
|