1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-28 11:30:31 -04:00

22 lines
1.0 KiB
HTML

{{- $optimized := partial "functions/optimize-image" . -}}
{{- with .Inner }}
<figure>
{{ with $.Get "link" }}<a class="no-underline" href="{{ . }}"{{ if strings.HasPrefix . "http" }} target="_blank" rel="noopener"{{ end }}>{{ end }}
<picture>
<img src="{{ $optimized.Permalink }}" width="{{ $optimized.Width }}" height="{{ $optimized.Height }}"
alt="{{ . | $.Page.RenderString | plainify | safeHTML }}" title="{{ . | $.Page.RenderString | plainify | safeHTML }}">
</picture>
{{ if $.Get "link" }}</a>{{ end }}
<figcaption>{{ . | $.Page.RenderString | safeHTML }}</figcaption>
</figure>
{{- else -}}
<p class="image">
{{ with .Get "link" }}<a class="no-underline" href="{{ . }}"{{ if strings.HasPrefix . "http" }} target="_blank" rel="noopener"{{ end }}>{{ end }}
<img src="{{ $optimized.Permalink }}" width="{{ $optimized.Width }}" height="{{ $optimized.Height }}"
{{- with .Get "alt" }} alt="{{ . | safeHTML }}" title="{{ . | safeHTML }}"{{ end }}>
{{ if .Get "link" }}</a>{{ end }}
</p>
{{- end }}