[pmwiki-users] Image Attachments and sub-directories

DaveG pmwiki at solidgone.com
Sun May 21 10:25:54 CDT 2006


I'm probably incorrect, but I think what you're proposing is for 
uploading files to a subdirectory. What I'd like to do is refer to 
already uploaded content.

Ben Wilson wrote:
> On 5/20/06, DaveG <pmwiki at solidgone.com> wrote:
>> I have a page in a group MyGroup.PageName. This particular page has a
>> lot of images and I'd like to store them in their own sub-directory.
>> Thus the images are in uploads/MyGroup/subdir.
> . . . [snip] . . .
>>
>> What syntax should I use?
> 
> 
> You may want to influence $UploadPrefixFmt. Its default is '/$Group',
> and you want something like '/$Group/images'. However, that would
> affect all uploads. So, you need a way to tell it when to affect this
> variable, and when to remain silent.
> 
> Perhaps interject a little subroutine? What I've coded below is a
> rough draft. What I'm doing is interjecting a checksum routine before
> the actual uploading of the page. I'm using the fact that PmWiki
> already tracks which extensions are images via a fairly universal
> standard--so I won't hardcode.
> 
> So, the routine extracts the extension, checks against the known image
> formats, then appends the "image" subdirectory to UploadPrefixFmt when
> we have a recognized image format.
> 
>    $HandleActions['postupload'] = 'PrefixImages'; #Defaults to
> HandlePostUpload();
> 
>    function PrefixImages($p, $a='upload') {
>        global $UploadExts, $UploadPrefixFmt
>        $upname = $_REQUEST['upname'];
>        if ($upname=='') {
>            $uploadfile = $_FILES['uploadfile'];
>            $upname=$uploadfile['name']; }
> 
>        $ext = split('.', $upname);
>        $xtype = split('/', $UploadExts[$ext[-1]]);
>        if ($xtype[0] == 'image') $UploadPrefixFmt .= '/images';
>        HandlePostUpload($p, $a); } # Returning the fish to the stream.
> 




More information about the pmwiki-users mailing list