Attachment 'IMG.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - IMG Macro
4
5 Creates an image with optional link.
6
7 Usage:
8
9 [[IMG(src)]] - create an image using src url
10
11 [[IMG(src, href)]] - create an image using src, linkinng to href
12
13 This macro is useful when your image url does not use the common format
14 like png, gif or jpg, or created dynamically by another script, like
15 src="http://example.com/image.php?name=123"
16
17 @copyright: 2005 by Josselin Mouette, Nir Soffer
18 @license: GNU GPL, see COPYING for details.
19 """
20
21 Dependencies = []
22
23 def execute(macro, args):
24 # Check arguments, return raw markup for bad call
25 if args == None:
26 return macro.formatter.text('[[IMG]]')
27 arguments = [item.strip() for item in args.split(',')]
28 # It does not make sense to call with empty argument for this script
29 if len(arguments) > 2 or '' in arguments:
30 return macro.formatter.text('[[IMG(%s)]]' % args)
31
32 # Render a link with an image or just an image
33 f = macro.formatter
34 try:
35 src, href = arguments
36 return f.url(1, href) + f.image(src=src) + f.url(0)
37 except ValueError:
38 src = arguments[0]
39 return f.image(src=src)
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.