Debian Codegraph @

tests/demo-project/templates/page.html

raw
1 {% extends "layout.html" %}
2 {% block body %}
3 <h1>{{ this.title }}</h1>
4 {{ this.body }}
5 {% for img in this.attachments.images %}
6 {# use half of test.jpg's dimensions (384 x 512) #}
7 {% set tw = img.thumbnail(192) %}
8 <img src="{{ tw|url }}" width="{{ tw.width }}" height="{{ tw.height }}">
9
10 {% set th = img.thumbnail(height=256) %}
11 <img src="{{ th|url }}" width="{{ th.width }}" height="{{ th.height }}">
12
13 {# this should have exactly the same result as above #}
14 {% set twh = img.thumbnail(width=256, height=256) %}
15 <img src="{{ twh|url }}" width="{{ twh.width }}" height="{{ twh.height }}">
16
17 {% set tq = img.thumbnail(192, 256, quality=20) %}
18 <img src="{{ tq|url }}" width="{{ tq.width }}" height="{{ tq.height }}">
19
20 {% set tc = img.thumbnail(300, 100, mode="crop") %}
21 <img src="{{ tc|url }}" width="{{ tc.width }}" height="{{ tc.height }}">
22
23 {% set ts = img.thumbnail(300, 100, mode="stretch") %}
24 <img src="{{ ts|url }}" width="{{ ts.width }}" height="{{ ts.height }}">
25
26 {# larger than original#}
27 {% set t0 = img.thumbnail(400, 600, upscale=True) %}
28 <img alt="original" src="{{ t0|url }}" width="{{ t0.width }}" height="{{ t0.height }}">
29 {% endfor %}
30
31 {# Not all subpages have a video clip, so we test for that here #}
32 {% if this.attachments.videos.count() %}
33 {% set video = this.attachments.videos|first %}
34 <video src="{{ video|url }}" autoplay loop></video>
35
36 {# We can only render this if ffmpeg/ffprobe is available #}
37 {% if video.width is defined %}
38 {% set td = video.frame().thumbnail() %}
39 <img src="{{ td|url }}" width="{{ td.width }}" height="{{ td.height }}">
40
41 {% set tv = video.frame(0).thumbnail(160) %}
42 <img src="{{ tv|url }}" width="{{ tv.width }}" height="{{ tv.height }}">
43
44 {% set sq = video.frame(2).thumbnail(160, 160, mode="crop") %}
45 <img src="{{ sq|url }}" width="{{ sq.width }}" height="{{ sq.height }}">
46 {% endif %}
47 {% endif %}
48 {% endblock %}