file_upload.pt
1.81 KB
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
<p tal:define="preview_url cstruct.get('preview_url');
css_class css_class|field.widget.css_class;
style style|field.widget.style;
preview_url cstruct.get('preview_url')|'';
ext str(cstruct.get('filename').split('.')[-1:][0]).lower()|[];
fname str(cstruct.get('filename'))|'';
delete cstruct.get('delete')|'';
ext str(cstruct.get('filename').split('.')[-1:][0]).lower()|[];
img ['jpg', 'jpeg', 'gif', 'png', 'svg', 'eps', 'psd'];
video ['avi', 'mov', 'mpv'];
pdf ['pdf'];
">
<img tal:condition="ext in img" id="preview-${oid}" alt="" src="${preview_url}"
style="${style}"
onload="window.URL.revokeObjectURL(this.src);"></img>
<video tal:condition="ext in video" style="${style}" controls
src="${preview_url}" type="video/${ext}">
Your browser does not support the video tag.
</video>
<!-- Preview Video -->
<video tal:condition="ext=='mp4'"
controls
style="${style}"
src="${preview_url}"
type="video/mp4">
Your browser does not support the video tag.
</video>
<!-- Preview PDF -->
<tal:block tal:condition="ext in pdf">
<embed src="${preview_url}"
type="application/pdf"
width="100%"
height="600px"
style="${style or 'border:1px solid #ddd;border-radius:4px;'}" />
<p>
<a href="${preview_url}" target="_blank">Buka PDF di tab baru</a>
</p>
</tal:block>
<tal:block tal:condition="preview_url and ext in ['jpg','jpeg','png','bmp','gif']">
<img src="${structure: preview_url}" style="width:100px;height:auto;"></img>
<br>
</tal:block>
<a class="label label-default" href="${structure: preview_url}"
target="_blank"><i class="fa fa-search"></i> View</a>
</p>