aboutsummaryrefslogtreecommitdiff
path: root/generators/hugo/themes/tdro/layouts/_default/_markup/render-image.html
blob: 5307cc27b1ef28a1d92f9ebc0a6438802ce5c9be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{{- $source      := $.Destination | safeURL -}}
{{- $localPath   := print "public/" $source -}}
{{- $remoteImage := resources.GetRemote $source -}}
{{- $width       := "" -}}
{{- $height      := "" -}}

{{- with $remoteImage -}}
  {{- with .Err -}}
    {{- if fileExists $localPath -}}
      {{- $localImage := imageConfig $localPath -}}
      {{- with $localImage -}}
        {{- $width  = .Width -}}
        {{- $height = .Height -}}
      {{- end -}}
    {{- else -}}
      {{- $source = print "/images/thumbnails/placeholder.png" -}}
      {{- $localPath = print "static/" $source -}}
      {{- $localImage := imageConfig $localPath -}}
      {{- with $localImage -}}
        {{- $width  = .Width -}}
        {{- $height = .Height -}}
      {{- end -}}
    {{- end -}}
  {{- else -}}
    {{- $width  = .Width -}}
    {{- $height = .Height -}}
  {{ end }}
{{ end }}

{{- /* This comment removes trailing newlines. */ -}}
<figure>
  <a href="{{ $source }}" onclick="return false;">
    <img data-image-zoom
      src="{{ $source }}"
      alt="{{ $.Text | htmlUnescape }}"
      title="{{ $.Text | htmlUnescape }}"
      width="{{ $width }}"
      height="{{ $height }}"
    />
  </a>
{{ if $.Title }}
<figcaption class="has-text-grey-dark">{{ $.Title | markdownify }}</figcaption>
{{ end -}}
</figure>
{{- /* This comment removes trailing newlines. */ -}}