blob: 9684c5a3ba31460da6f2cb97997a7b9473cbddc4 (
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
|
{{ $imageName := (index .Params 0)}}
{{ $subtitle := (index .Params 1)}}
{{ $newSize := (index .Params 2) }}
<!-- Try to find image locally in the posts folder -->
{{ $originalImage := .Page.Resources.GetMatch $imageName }}
<!-- Try to find image from "/images" folder -->
{{ if not $originalImage}}
{{ $imagesPage := .Site.GetPage "/images" }}
{{ $originalImage = $imagesPage.Resources.GetMatch $imageName }}
{{ end }}
{{ .Scratch.Set "image" ($originalImage.Resize $newSize) }}
{{ $scaledImage := .Scratch.Get "image" }}
<figure>
<a href={{ $originalImage.Permalink }} target="_blank">
<center>
<img class="embedded-image" src={{ $scaledImage.Permalink }}>
</center>
</a>
<figcaption>
<h4>
<center>
{{ markdownify $subtitle }} ({{ printf "%.*f" 2 (div (len $originalImage.Content) 1000000.0) }}MB)
</center>
</h4>
</figcaption>
</figure>
|