/
RenderTopicThumbnail.txt
118 lines (105 loc) · 3.46 KB
/
RenderTopicThumbnail.txt
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
%META:TOPICINFO{author="ProjectContributor" comment="" date="1418752972" format="1.1" version="1"}%
%META:TOPICPARENT{name="TopicFunction"}%
%TOC{depth="2"}%
---++ Documentation
%STARTSECTION{"documentation"}%
This function gets the first image attachment from a topic and creates
a 48x48 thumbnail using <nop>ImagePlugin. The attachment taken must end
with =jpeg, jpg, gif, bmp, svg or png=. If there are multiple image attachments
then the first one ordered by comment and name is taken. The empty string
is returned if no image attachment is found.
---+++++ Parameters
* OBJECT: topic to generate a thumbnail for
* ALIGN: optional alignment of image, defaults to right
* SIZE: optional size of thumbnail
* TYPE: image rendering type, see documentation of <nop>ImagePlugin, defaults to simple
* CROP
* SORT: specifies which image to chose from the attachments, defaults to =comment:name= which will take the one that sorts first wrt the comment, falling back to the name
%ENDSECTION{"documentation"}%
---++ Implementation
<verbatim class="tml">
%STARTINCLUDE%%DBCALL{"Applications.RenderTopicThumbnail"
section="%IF{
"'%ATTACHMENTS{"%OBJECT%" attr=".*t.*" format="yes"}%'='yes'"
then="thumbnailed"
else="defaultthumbnail"
}%"
object="%OBJECT%"
align="%ALIGN{default="right"}%"
size="%SIZE{default="48x48>"}%"
type="%TYPE{default="simple"}%"
crop="%CROP{default="center"}%"
sort="%SORT{default="comment:name"}%"
}%%STOPINCLUDE%
</verbatim>
<verbatim class="tml">
%STARTSECTION{"thumbnailed"}%%ATTACHMENTS{
"%object%"
attr=".*t.*"
warn="off"
hidenull="on"
format="$percntIMAGE{
\"$name\"
topic=\"$web.$topic\"
align=\"%align%\"
type=\"%type%\"
size=\"%size%\"
crop=\"%crop%\"
title=\"\"
tooltip=\"on\"
warn=\"off\"
}$percnt"
}%%ENDSECTION{"thumbnailed"}%
%STARTSECTION{"defaultthumbnail"}%%ATTACHMENTS{
"%object%"
name=".*\.(jpe?g|gif|png|bmp|svg|JE?PG|GIF|PNG|BMP|SVG)"
warn="off"
limit="1"
sort="%sort%"
reverse="%IF{"'%sort%' = 'date'" then="on" else="off"}%"
hidenull="on"
format="$percntIMAGE{
\"$name\"
topic=\"$web.$topic\"
align=\"%align%\"
type=\"%type%\"
size=\"%size%\"
crop=\"%crop%\"
title=\"\"
tooltip=\"on\"
warn=\"off\"
}$percnt"
}%%ENDSECTION{"defaultthumbnail"}%
</verbatim>
---++ Test
%DBCALL{"%WEB%.%TOPIC%"
OBJECT="%WIKIUSERNAME%"
ALIGN="left"
}%
%DBCALL{"%TOPIC%"
OBJECT="%WIKIUSERNAME%"
SORT="date"
ALIGN="left"
SIZE="100x100"
}%
%CLEAR%
---++ List of all attachments at %WIKIUSERNAME%
<a name="sort"></a>
%ATTACHMENTS{
"%WIKIUSERNAME%"
name=".*\.(jpe?g|gif|png|JE?PG|GIF|PNG)"
sort="%URLPARAM{"sort"}%"
hidenull="on"
header="| *#* | *Name* | *Date* | *Size*| *Comment* | *Image* |$n"
format="| $index | <nop>$name | $date | $size | $comment | <img src='$url' width='50' /> |"
}%
</div>
%DBCALL{"Applications.RenderFunctionCallers"}%
---++ Copyright
© 2006-2014 Michael Daum http://michaeldaumconsulting.com
%DBCALL{"Applications.GnuGeneralPublicLicense" section="notice"}%
%META:FORM{name="Applications.ApplicationTopic"}%
%META:FIELD{name="TopicType" title="TopicType" value="DocuTopic, TopicFunction"}%
%META:FIELD{name="TopicTitle" attributes="" title="<nop>TopicTitle" value=""}%
%META:FIELD{name="Summary" attributes="c" title="Summary" value="Display thumbnail image for a topic"}%
%META:FIELD{name="WikiApplication" attributes="" title="WikiApplication" value="WikiWorkbench"}%