1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-12-03 04:18:57 -05:00

support full HTML captions for image shortcode

This commit is contained in:
2019-12-17 11:39:23 -05:00
parent 1b97c6b2de
commit c87bfd7797
22 changed files with 111 additions and 113 deletions

View File

@@ -62,6 +62,11 @@
p.center, p.image, p.caption {
text-align: center;
}
p.caption {
margin-top: -1em;
font-size: 0.9em;
color: #5e5e5e;
}
header {
width: 100%;
background-color: #f9f9f9;

View File

@@ -29,7 +29,8 @@
<p class="image">
<amp-img
{{ with .Get "alt" }}alt="{{ . }}"{{ end }}
{{- with .Get "alt" }} alt="{{ . | safeHTMLAttr }}" title="{{ . | safeHTMLAttr }}"{{ end }}
{{- with .Inner }} alt="{{ . | plainify | safeHTMLAttr }}" title="{{ . | plainify | safeHTMLAttr }}"{{ end }}
src="{{ $image.Permalink }}"
width="{{ $displayWidth }}"
height="{{ $displayHeight }}"
@@ -37,4 +38,4 @@
</amp-img>
</p>
{{- with .Get "caption" }}<p class="caption"><em>{{ . }}</em></p>{{ end -}}
{{- with .Inner }}<p class="caption">{{ . | safeHTML }}</p>{{ end -}}

View File

@@ -27,19 +27,15 @@
{{- $displayWidth := $setWidth -}}
{{- $displayHeight := (math.Ceil (mul $origRatio $setWidth)) -}}
{{- if .Get "caption" -}}
{{ with .Inner }}
<figure>
<picture>
{{- else -}}
<p>
{{- end -}}
<img src="{{ $image.Permalink }}" width="{{ $displayWidth }}" height="{{ $displayHeight }}"
{{- with .Get "alt" }} alt="{{ . }}"{{ end }}
{{- with .Get "caption" }} title="{{ . }}"{{ end }}>
{{- with .Get "caption" -}}
<img src="{{ $image.Permalink }}" width="{{ $displayWidth }}" height="{{ $displayHeight }}"
alt="{{ . | plainify | safeHTMLAttr }}" title="{{ . | plainify | safeHTMLAttr }}">
</picture>
<figcaption>{{ . }}</figcaption>
<figcaption>{{ . | safeHTML }}</figcaption>
</figure>
{{- else -}}
</p>
{{- end -}}
{{ else }}
<p><img src="{{ $image.Permalink }}" width="{{ $displayWidth }}" height="{{ $displayHeight }}"
{{- with .Get "alt" }} alt="{{ . | safeHTMLAttr }}" title="{{ . | safeHTMLAttr }}"{{ end }}></p>
{{ end }}

View File

@@ -29,7 +29,7 @@
<p style="text-align: center;">
<img src="{{ $image.Permalink }}" width="{{ $displayWidth }}" height="{{ $displayHeight }}"
{{- with .Get "alt" }} alt="{{ . }}"{{ end }}
{{- with .Get "caption" }} title="{{ . }}"{{ end }}>
{{ with .Get "caption" }}<br>{{ . }}{{ end -}}
{{- with .Get "alt" }} alt="{{ . | safeHTMLAttr }}" title="{{ . | safeHTMLAttr }}"{{ end }}
{{- with .Inner }} alt="{{ . | plainify | safeHTMLAttr }}" title="{{ . | plainify | safeHTMLAttr }}"{{ end }}>
{{ with .Inner }}<br>{{ . | safeHTML }}{{ end -}}
</p>