]> sipb.mit.edu Git - ikiwiki.git/blob - doc/ikiwiki/pagespec/attachment.mdwn
Merge branch 'master' into tova
[ikiwiki.git] / doc / ikiwiki / pagespec / attachment.mdwn
1 [[!meta robots="noindex, follow"]]
2 [[!if test="enabled(attachment)"
3      then="This wiki has attachments **enabled**."
4      else="This wiki has attachments **disabled**."]]
5
6 If attachments are enabled, the wiki admin can control what types of
7 attachments will be accepted, by entering a [[ikiwiki/PageSpec]] in the
8 "Allowed Attachments" field of their preferences page.
9
10 For example, to limit arbitrary files to 50 kilobytes, but allow
11 larger mp3 files to be uploaded by joey, a something like this could be
12 used:
13   
14         (user(joey) and *.mp3 and mimetype(audio/mpeg) and maxsize(15mb)) or (!ispage() and maxsize(50kb))
15
16 The regular [[ikiwiki/PageSpec]] syntax is expanded with thw following
17 additional tests:
18
19 * maxsize(size)
20
21   Tests whether the attachment is no larger than the specified size.
22   The size defaults to being in bytes, but "kb", "mb", "gb" etc can be
23   used to specify the units.
24   
25 * minsize(size)
26
27   Tests whether the attachment is no smaller than the specified size.
28
29 * ispage()
30
31   Tests whether the attachment will be treated by ikiwiki as a wiki page.
32   (Ie, if it has an extension of ".mdwn", or of any other enabled page
33   format).
34
35   So, if you don't want to allow wiki pages to be uploaded as attachments,
36   use `!ispage()` ; if you only want to allow wiki pages to be uploaded
37   as attachments, use `ispage()`.
38
39 * user(username)
40
41   Tests whether the attachment is being uploaded by a user with the
42   specified username. If openid is enabled, an openid can also be put here.
43
44 * ip(address)
45
46   Tests whether the attacment is being uploaded from the specified IP
47   address.
48
49 * mimetype(foo/bar)
50
51   This checks the MIME type of the attachment. You can include a glob
52   in the type, for example `mimetype(image/*)`.