%ATTACHMENT{ name="filename" topic="TopicName" web="Webname" label="sometimes_text_sometimes_magic" }%
This apparently trivial plugin turns out to be quite useful. Besides syntactic sugar, it actually makes previously hard things easier!
Until now, referencing an attachment in a TWiki topic has required escape to HTML, with lots of ugly TWiki variables like %PUBURLPATH% and %ATTACHURL% to do the simplest things. AttachLinkPlugin fixes that!
Further, it makes it easy to have clickable images - for example, thumbnails that when clicked, expand to a full-size picture.
Here are the syntax details:
%ATTACHMENT{ "foo.jpg" }% Create a link to foo.jpg in the current topic, which will look like: foo.jpg underlined. (Can WYSIWYG underline?)
%ATTACHMENT{ "foo.jpg" label="The foomobile afloat" }% gives you a hyperlink to the same file, like this: The foomobile afloat
%ATTACHMENT{ "foo.jpg" label="%IMG{ "foo_thumb.jpg" align="left" width="40" class="none" }%" }% will display foo_thumb.jpg inline. You can click on the image, and if you do, foo.jpg will display.
So you essentially have the power of [[TWiki.WikiWord][PrettyText]] links, for images and other attachments. And anything else that will take an HTML anchor tag.
A rather surprising result for less than 10 executable statements of perl. If %ATT% is not in use (do we have a registry of variables?), I would be receptive to adding the line to add it as an alias for %ATTACHMENT% - I already have 10s of thousands of instances of %ATTACHMENT%
Enjoy it as much as I do.
Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%
, i.e. %ATTACHLINKPLUGIN_SHORTDESCRIPTION%
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
File: | Description: |
---|---|
data/TWiki/AttachLinkPlugin.txt | Plugin topic |
lib/TWiki/Plugins/AttachLinkPlugin.pm | Plugin Perl module |
Plugin Author: | TWiki:Main.TimotheLitt |
Copyright: | © 2007, TWiki:Main.TimotheLitt, © 2007-2010 TWiki:TWiki.TWikiContributor |
License: | GPL (GNU General Public License) |
Plugin Version: | 19310 (2010-08-01) |
Change History: | |
2010-08-01: | TWikibug:Item6530 - doc fixes; changing TWIKIWEB to SYSTEMWEB |
20 Dec 2008: | Initial version |
TWiki Dependency: | $TWiki::Plugins::VERSION 1.1 |
CPAN Dependencies: | none |
Other Dependencies: | none |
Perl Version: | 5.005 |
TWiki:Plugins/Benchmark: | GoodStyle nn%, FormattedSearch nn%, AttachLinkPlugin nn% |
Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/AttachLinkPlugin |
Feedback: | http://TWiki.org/cgi-bin/view/Plugins/AttachLinkPluginDev |
Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/AttachLinkPluginAppraisal |
Related Topics: TWikiPlugins, DeveloperDocumentationCategory, AdminDocumentationCategory, TWikiPreferences