[pmwiki-users] What attachment operations do you want or need?
Eemeli Aro
eemeli at gmail.com
Tue May 4 14:06:59 CDT 2010
On 4 May 2010 17:15, Tegan Dowling <tmdowling at gmail.com> wrote:
> I'd like fault-tolerant name conversions or context-sensitive warnings and
> instructions. I'm thinking of the ways that naive editors get tripped up...
>
> Maybe an option for case insensitive filename handling, so MyPic.JPG is
> displayed when the editor keys Attach:mypic.jpg (or vice versa)?
> And space/punctuation stripping, so that Attach:My Picture.jpg or
> Attach:My-picture.jpg or My'picture.jpg will render MyPicture.jpg if it
> exists?
> And if the user uploads My Picture.JPG, or My.Picture.jpg, then
> Attach:MyPicture.jpg will render it?
You should be able to do this by setting a value for $UploadNameChars
and/or $MakeUploadNamePatterns. These are globals used by a function
MakeUploadName (in scripts/upload.php), which transforms a string into
an acceptable uploaded file name.
So to remove spaces from file names, use this:
$UploadNameChars = "-\\w.";
or if you also want to make all uploaded file names case-insensitive
(by forcing them to be lower-case):
$UploadNameChars = "-\\w.";
$MakeUploadNamePatterns = array(
"/[^$UploadNameChars]/" => '',
'/^.*$/e' => 'strtolower("$0")',
'/^[^[:alnum:]_]+/' => '',
'/[^[:alnum:]_]+$/' => '');
Note that these rules get applied both when you're uploading and
downloading a file, which means that you're fine as long as you don't
have previously uploaded files with names like "the document.txt" or
"MyImage.jpg"; those you'll need to rename so they match your new
naming convention.
eemeli
More information about the pmwiki-users
mailing list