mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
19 lines
734 B
HTML
19 lines
734 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" -}}
|
|
{{- /* placed remote image in public/images/remote/ */ -}}
|
|
{{- $resource = $remoteResource | resources.Copy (add "/images/remote/" $remoteResource.Name) -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- return $resource -}}
|