fix: fig-img short code
This commit is contained in:
parent
298cedf57d
commit
5f91c6ab3e
1 changed files with 30 additions and 5 deletions
|
@ -1,15 +1,37 @@
|
||||||
<figure class="figure fig-img {{ with .Get "class" }}{{ . }}{{ end }}">
|
{{/**
|
||||||
|
fig-img
|
||||||
|
how to use:
|
||||||
|
|
||||||
|
{{< fig-img
|
||||||
|
src="now.jpg"
|
||||||
|
options="500x500"
|
||||||
|
alt="The alt"
|
||||||
|
caption="The caption"
|
||||||
|
>}}
|
||||||
|
|
||||||
|
**/}}
|
||||||
|
{{- if .Get "single" -}}
|
||||||
|
<div class="single-figure-container">
|
||||||
|
{{ end }}
|
||||||
|
<figure class="figure {{ with .Get "class" }}{{ . }}{{ end }}">
|
||||||
{{- if .Get "link" -}}
|
{{- if .Get "link" -}}
|
||||||
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
|
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{ $options := .Get "options" }}
|
{{ $options := or (.Get "options") "500x500 center" }}
|
||||||
{{ $img := (.Page.Resources.GetMatch (.Get "src")).Fit $options }}
|
{{ $permalink := "" }}
|
||||||
<img src="{{ $img.RelPermalink }}"
|
{{ if hasPrefix (.Get "src") "https://" }}
|
||||||
|
{{ $permalink = .Get "src" }}
|
||||||
|
{{ else }}
|
||||||
|
{{ $permalink = ((.Page.Resources.GetMatch (.Get "src")).Fill $options).Permalink }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
<img
|
||||||
|
class="figure-img img-fluid"
|
||||||
|
src="{{ $permalink }}"
|
||||||
{{- if or (.Get "alt") (.Get "caption") }}
|
{{- if or (.Get "alt") (.Get "caption") }}
|
||||||
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
|
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
class="figure-img img-fluid rounded"
|
|
||||||
/><!-- Closing img tag -->
|
/><!-- Closing img tag -->
|
||||||
{{- if .Get "link" }}</a>{{ end -}}
|
{{- if .Get "link" }}</a>{{ end -}}
|
||||||
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
|
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
|
||||||
|
@ -28,4 +50,7 @@
|
||||||
</figcaption>
|
</figcaption>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</figure>
|
</figure>
|
||||||
|
{{- if .Get "single" -}}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue