Add post: 暗黑能天使
This commit is contained in:
17
layouts/partials/utils/get-image.html
Normal file
17
layouts/partials/utils/get-image.html
Normal file
@@ -0,0 +1,17 @@
|
||||
{{- $img := "" }}
|
||||
{{- $validKeyword := false }}
|
||||
{{- if .keyword }}
|
||||
{{- if (.context.Resources.ByType "image").GetMatch .keyword }}
|
||||
{{- $validKeyword = true}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $validKeyword }}
|
||||
{{- $img = ((.context.Resources.ByType "image").GetMatch .keyword).Permalink }}
|
||||
{{- else if or (hasPrefix .url "//") (or (hasPrefix .url "http://") (hasPrefix .url "https://")) }}
|
||||
{{- $img = (.url | absURL) }}
|
||||
{{- else if resources.GetMatch .url }}
|
||||
{{- $img = (resources.GetMatch .url).Permalink }}
|
||||
{{- else if .url }}
|
||||
{{- $img = (.url | absURL) }}
|
||||
{{- end }}
|
||||
{{- return $img }}
|
||||
Reference in New Issue
Block a user