-
Notifications
You must be signed in to change notification settings - Fork 9
/
figure.html
63 lines (56 loc) · 1.77 KB
/
figure.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<figure>
{% if link %}
<a href="{{ link }}">
{% endif %}
{% set imgpath = get_url(path=page.path ~ src) %}
{% set meta_path = "../static/"~page.path~src %}
{% set meta = get_image_metadata(path=meta_path) %}
{% if src is not ending_with("svg") %}
<picture>
<source srcset="{{ imgpath | replace(from="jpg", to="avif")}}" type="image/avif" />
<source srcset="{{ imgpath| replace(from="jpg", to="webp")}}" type="image/webp" />
{% endif %}
<img style="display:block" src="{{ imgpath}}"
{% if alt %}
alt="{{ alt }}"
{% elif caption %}
alt="{{ caption }}"
{% elif credits %}
alt="{{ credits }}"
{% endif %}
{% if invert %}
class="invert"
{% endif %}
{# Give the browser a hand by telling it the image width upfront #}
{# It will then reserve the necessary space and avoid layout changes #}
{% if width %}
width="{{ width }}"
{% elif meta.width %}
width="{{ meta.width }}"
{% endif %}
{% if height %}
height ="{{ height }}"
{% elif meta.height %}
height="{{ meta.height }}"
{% endif %}
/>
{% if src is not ending_with("svg") %}
</picture>
{% endif %}
{% if link %}
</a>
{% endif %}
{% if caption or credits %}
<figcaption>
{% if caption %}
{{ caption | markdown(inline=true) | safe }}
{% endif %}
{% if caption and credits %}
<br />
{% endif %}
{% if credits %}
Source: {{ credits | markdown(inline=true) | safe }}
{% endif %}
</figcaption>
{% endif %}
</figure>