Skip to content

Commit 9d4cbd6

Browse files
committed
add img shortcode
1 parent 512dbb5 commit 9d4cbd6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

layouts/shortcodes/img.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{ $src := (.Page.Resources.GetMatch (printf "**%s*" (.Get "src"))) }}
2+
{{- if .Get "link" -}}
3+
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
4+
{{- end }}
5+
<img {{ with .Get "class" }} class="{{ . }}"{{ end }} src="{{ if $src }}{{ $src.RelPermalink }}{{ else }}{{ .Get "src" }}{{ end }}"
6+
{{- if or (.Get "alt") (.Get "caption") }}
7+
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
8+
{{- end -}}
9+
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
10+
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
11+
/> <!-- Closing img tag -->
12+
{{- if .Get "link" }}</a>{{ end -}}

0 commit comments

Comments
 (0)