3 | | == Adding images == |
| 3 | = Adding images = |
| 4 | |
| 5 | Urls ending with `.png`, `.gif` or `.jpg` are no longer automatically interpreted as image links, and converted to `<img>` tags. |
| 6 | |
| 7 | You now have to use the ![[Image]] macro. The simplest way to include an image is to upload it as attachment to the current page, and put the filename in a macro call like `[[Image(picture.gif)]]`. |
| 8 | |
| 9 | In addition to the current page, it is possible to refer to other resources: |
| 10 | * `[[Image(wiki:WikiFormatting:picture.gif)]]` (referring to attachment on another page) |
| 11 | * `[[Image(ticket:1:picture.gif)]]` (file attached to a ticket) |
| 12 | * `[[Image(htdocs:picture.gif)]]` (referring to a file inside the [TracEnvironment environment] `htdocs` directory) |
| 13 | * `[[Image(source:/trunk/trac/htdocs/trac_logo_mini.png)]]` (a file in repository) |
| 14 | |
| 15 | ||= Wiki Markup =||= Display =|| |
| 16 | {{{#!td |
| 17 | {{{ |
| 18 | [[Image(htdocs:../common/trac_logo_mini.png)]] |
| 19 | }}} |
| 20 | }}} |
| 21 | {{{#!td |
| 22 | [[Image(htdocs:../common/trac_logo_mini.png)]] |
| 23 | }}} |
| 24 | |
| 25 | Embed an image in wiki-formatted text. |
| 26 | |
| 27 | The first argument is the file specification. The file specification may reference attachments in three ways: |
| 28 | |
| 29 | * {{{module:id:file}}}, where module can be either wiki or ticket, to refer to the attachment named file of the specified wiki page or ticket. |
| 30 | * {{{id:file}}}: same as above, but id is either a ticket shorthand or a Wiki page name. |
| 31 | * {{{file}}} to refer to a local attachment named 'file'. This only works from within that wiki page or a ticket. |
| 32 | Also, the file specification may refer to repository files, using the {{{source:file}}} syntax (source:file@rev works also). |
| 33 | |
| 34 | Files can also be accessed with a direct URLs; {{{/file}}} for a project-relative, {{{//file}}} for a server-relative, or {{{http://server/file}}} for absolute location of the file. The rfc2397 data URL scheme is also supported if the URL is enclosed in quotes. |
| 35 | |
| 36 | The remaining arguments are optional and allow configuring the attributes and style of the rendered {{{<img>}}} element: |
| 37 | |
| 38 | * digits and unit are interpreted as the size (ex. 120px, 25%) for the image |
| 39 | {{{right}}}, {{{left}}}, {{{center}}}, {{{top}}}, {{{bottom}}} and {{{middle}}} are interpreted as the alignment for the image (alternatively, the first three can be specified using {{{align=...}}} and the last three using {{{valign=...}}}) |
| 40 | * {{{link=some TracLinks...}}} replaces the link to the image source by the one specified using a TracLinks. If no value is specified, the link is simply removed. |
| 41 | * {{{inline}}} specifies that the content generated be an inline XHTML element. By default, inline content is not generated, therefore images won't be rendered in section headings and other one-line content. |
| 42 | * {{{nolink}}} means without link to image source (deprecated, use {{{link=}}}) |
| 43 | * {{{key=value}}} style are interpreted as HTML attributes or CSS style indications for the image. Valid keys are: |
| 44 | * align, valign, border, width, height, alt, title, longdesc, class, margin, margin-(left,right,top,bottom), id and usemap |
| 45 | * {{{border}}}, {{{margin}}}, and {{{margin-}}}* can only be a single number (units are pixels). |
| 46 | * {{{margin}}} is superseded by {{{center}}} which uses auto margins |
| 47 | |
| 48 | Examples: |
| 49 | {{{ |
| 50 | [[Image(photo.jpg)]] # simplest |
| 51 | [[Image(photo.jpg, 120px)]] # with image width size |
| 52 | [[Image(photo.jpg, right)]] # aligned by keyword |
| 53 | [[Image(photo.jpg, nolink)]] # without link to source |
| 54 | [[Image(photo.jpg, align=right)]] # aligned by attribute |
| 55 | }}} |
| 56 | You can use an image from a wiki page, ticket or other module. |
| 57 | {{{ |
| 58 | [[Image(OtherPage:foo.bmp)]] # from a wiki page |
| 59 | [[Image(base/sub:bar.bmp)]] # from hierarchical wiki page |
| 60 | [[Image(#3:baz.bmp)]] # from another ticket |
| 61 | [[Image(ticket:36:boo.jpg)]] # from another ticket (long form) |
| 62 | [[Image(source:/img/bee.jpg)]] # from the repository |
| 63 | [[Image(htdocs:foo/bar.png)]] # from project htdocs dir |
| 64 | [[Image(shared:foo/bar.png)]] # from shared htdocs dir (since 1.0.2) |
| 65 | }}} |