Questions answered by this recipe
How can I get
Attach: links to display by default without the "Attach:" prefix?
Add the following lines to your config.php or local customization file:
- PHP 5.4 or older:
Markup('Attach', '>img', "/\\bAttach:([^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars])/e", "Keep(MakeLink(\$pagename,'$0','$1'),'L')");
- PHP 5.5 or newer, PmWiki 2.2.58+:
Markup_e('Attach', '>img', "/\\bAttach:([^\\s$UrlExcludeChars]*[^\\s.,?!$UrlExcludeChars])/", "Keep(MakeLink(\$pagename,\$m,\$m),'L')");
This will cause
Attach:something.txt to appear as "
To have the "Attach:" to still appear when creating a new attachment (but not for an existing attachment), also add
$LinkUploadCreateFmt = "<a class='createlinktext' href='\$LinkUpload'>Attach:\$LinkText</a><a class='createlink' href='\$LinkUpload'> Δ</a>";
After this modification, authors can still create links with the "Attach:" displayed by using the double-bracket form of link (i.e.,
This modification has been applied to the Cookbook group on pmwiki.org.
One may also use
[[Attach:somepage.txt | sometext]]
to get the attachment link shown with another text.
- Pm, 2004-12-20
See discussion at AttachLinks-Talk