On Tuesday 22 March 2011 04:21:51, Steven Leite wrote : > Part of what it does is reads an existing wiki pages and isolates any > lines that contain "Attach:". > > Once the lines are isolated, it extracts the file name by taking > everything after Attach: but before .jpg to determine the path of the file.
It looks like you are writing a replacement of the LunkUpload() function from the file scripts/upload.php. > *The problem *is that if a user has changed the default value of > $UploadPrefixFmt to use slashes instead of dots (for example), or the > user has enabled Per Page attachments instead of Group attachments, the > script breaks. > > I need a way to determine the upload path (or URL) to the image when > given nothing more than what is on the wiki page (Eg. Attach: > Group/Name/File.jpg) > > Another problem which I foresee happening is what if a user specifed > Attach:File.jpg without specifying the Group or Page name where the > image is to be stored? That's another problem, but I haven't got to > that bridge yet. You can look how the function LinkUpload() works, it finds the attachment path on the filesystem ($filepath) and its url address (the last $path) based on the Attach:Group.Name/img.jpg markup and $UploadPrefixFmt and other variables. Your own function could get all the information LinkUploads gets if you use such a line to replace it: $LinkFunctions['Attach:'] = 'MyGalleryFunction'; You should really try to use $UploadFileFmt and $UploadPrefixFmt because an admin could have organized the uploads directories differently from what you can imagine, for example uploads/file.jpg uploads/Group/file.jpg uploads/Group/Page/file.jpg uploads/Group.Page/file.jpg uploads/Group/Group.Page/file.jpg files/G/Gr/Group/P/Pa/Page/file.jpg see PerGroupSubDirectories If you use $UploadFileFmt and/or $UploadPrefixFmt, you can have these paths automatically, like LinkUpload() does. Additionally, you could look at other gallery recipes, notably Mini has a markup similar to Attach: although slightly more complex, and UploadPlus which finds the attachments both in Group/ and in Group/Page upload directories. http://www.pmwiki.org/wiki/Cookbook/UploadPlus http://www.pmwiki.org/wiki/Cookbook/Mini Petko _______________________________________________ pmwiki-devel mailing list pmwiki-devel@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-devel