2020-03-22 19:09:09 +01:00
|
|
|
{{- if .Page.Site.Params.BookPortableLinks -}}
|
2020-03-07 18:47:16 +01:00
|
|
|
{{- template "portable-image" . -}}
|
2020-03-22 19:09:09 +01:00
|
|
|
{{- else -}}
|
2020-03-07 18:47:16 +01:00
|
|
|
<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title }}title="{{ . }}"{{ end }}/>
|
2020-03-22 19:09:09 +01:00
|
|
|
{{- end -}}
|
2020-03-07 18:47:16 +01:00
|
|
|
|
|
|
|
{{- define "portable-image" -}}
|
|
|
|
{{- $isRemote := or (in .Destination "://") (strings.HasPrefix .Destination "//") }}
|
|
|
|
{{- if not $isRemote }}
|
|
|
|
{{- $path := print .Page.File.Dir .Destination }}
|
|
|
|
{{- if strings.HasPrefix .Destination "/" }}
|
|
|
|
{{- $path = print "/static" .Destination }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if not (fileExists $path) }}
|
|
|
|
{{- warnf "Image '%s' not found in '%s'" .Destination .Page.File }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title }}title="{{ . }}"{{ end }}/>
|
|
|
|
{{- end -}}
|