[pmwiki-users] grab Attach: url in a PTV?
Eemeli Aro
eemeli at gmail.com
Wed Jun 3 04:24:24 CDT 2009
2009/6/3 SteP <step.list+pmwiki at gmail.com>:
> Hi all, is it possible to set a PTV to the path computed by Attach: ?
>
> What I'm looking for is a way to use attachments as markup parameters.
MarkupExpressions
<http://www.pmwiki.org/wiki/PmWiki/MarkupExpressions> might be your
friend here. Haven't tested this, but try adding the following to your
config file:
$MarkupExpr['attachurl'] = 'ME_attachurl($pagename,$args[0])';
function ME_attachurl( $pagename, $path ) {
global $UploadFileFmt, $UploadUrlFmt,
$UploadPrefixFmt, $EnableDirectDownload;
if (preg_match('!^(.*)/([^/]+)$!', $path, $match)) {
$pagename = MakePageName($pagename, $match[1]);
$path = $match[2];
}
$upname = MakeUploadName($pagename,$path);
return PUE(FmtPageName(IsEnabled($EnableDirectDownload, 1)
? "$UploadUrlFmt$UploadPrefixFmt/$upname"
: "{\$PageUrl}?action=download&upname=$upname",
$pagename));
}
And then using this in markup:
{(attachurl cover.jpg)}
eemeli
More information about the pmwiki-users
mailing list