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
- TOOLTIP: switch on/off tooltips for thumbnails, defaults to
on
- 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%%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="on"}%"
sort="%SORT{default="comment:name"}%"
}%%STOPINCLUDE%
%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=\"%TOOLTIP{default="on"}%\"
warn=\"off\"
output=\"png\"
}$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=\"%TOOLTIP{default="on"}%\"
warn=\"off\"
output=\"png\"
}$percnt"
}%%ENDSECTION{"defaultthumbnail"}%
Test
List of all attachments at WikiGuest
Copyright
© 2006-2015 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.