Documentation
This function gets the first image attachment from a topic and creates
a 48x48 thumbnail using 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 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
Implementation
%STARTINCLUDE%%ATTACHMENTS{
"%OBJECT%"
name=".*\.(jpe?g|gif|png|bmp|svg|JE?PG|GIF|PNG|BMP|SVG)"
warn="off"
limit="1"
sort="%SORT{default="comment:name"}%"
reverse="%IF{"'%SORT%' = 'date'" then="on" else="off"}%"
hidenull="on"
format="$percntIMAGE{
\"$name\"
topic=\"$web.$topic\"
align=\"%ALIGN{default="right"}%\"
type=\"%TYPE{default="simple"}%\"
size=\"%SIZE{default="48x48>"}%\"
crop=\"%CROP{default="northwest"}%\"
title=\"\"
tooltip=\"on\"
warn=\"off\"
}$percnt"
}%%STOPINCLUDE%
Test
%ATTACHMENTS{
"Main.WikiGuest"
name=".*\.(jpe?g|gif|png|bmp|svg|JE?PG|GIF|PNG|BMP|SVG)"
warn="off"
limit="1"
sort="comment:name"
reverse="off"
hidenull="on"
format="$percntIMAGE{
\"$name\"
topic=\"$web.$topic\"
align=\"left\"
type=\"simple\"
size=\"48x48>\"
crop=\"northwest\"
title=\"\"
tooltip=\"on\"
warn=\"off\"
}$percnt"
}%
%ATTACHMENTS{
"Main.WikiGuest"
name=".*\.(jpe?g|gif|png|bmp|svg|JE?PG|GIF|PNG|BMP|SVG)"
warn="off"
limit="1"
sort="date"
reverse="on"
hidenull="on"
format="$percntIMAGE{
\"$name\"
topic=\"$web.$topic\"
align=\"left\"
type=\"simple\"
size=\"100x100\"
crop=\"northwest\"
title=\"\"
tooltip=\"on\"
warn=\"off\"
}$percnt"
}%
List of all attachments at WikiGuest
%ATTACHMENTS{
"Main.WikiGuest"
name=".*\.(jpe?g|gif|png|JE?PG|GIF|PNG)"
sort=""
hidenull="on"
header="|
# |
Name |
Date |
Size*| *Comment |
Image |$n"
format="| $index | $name | $date | $size | $comment |
|"
}%
Copyright
© 2006-2013 Michael Daum
http://michaeldaumconsulting.com
This file is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read the
LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.