[pmwiki-users] conditional for attachments

Patrick R. Michaud pmichaud at pobox.com
Tue Nov 13 09:33:08 CST 2007


On Tue, Nov 13, 2007 at 08:54:30AM -0600, Tegan Dowling wrote:
> On Nov 13, 2007 8:42 AM, noskule <noskule at gmx.net> wrote:
> > Patrick R. Michaud schrieb:
> > > On Tue, Nov 13, 2007 at 02:44:45PM +0100, noskule wrote:
> > >> hi list
> > >> is there a way to find out if a attachment with a given name exists?
> > >> That works the same way as exists for pages does?
> > >>
> > >> In the documentation I found only a way to find out it any attachemt exists.
> > >
> > > We don't yet have a conditional for testing for specific attachments.
> > > I could probably write one as a recipe, though.
> >
> > that would be cool, one thing that I stepped over was, that if user
> > upload a profile portrait they will upload it in different formats like
> > jpg, png, so the conditional should be able ot detect the filename
> > without the extension. But if wildcards ar supported this will probably
> > work anyway .. .
> >
> > (:if attachment {*$Group}/{*$Name}-Portrait.*:)
>
> 
> FYI, there's a least one other person who would use this, if it
> existed.  I'd use it on profile pages, as noskule does, and also on
> some blog-like pages.

I wasn't planning on supporting wildcards in the conditional --
would that be very important?

Also, do we really want to solve this with (:if ... :)
conditionals, or would it be better to come up with an Attach:-like
syntax that can automatically find the correct image?  E.g., so 
someone could write 

  Attach:Profiles/Pm/image 

and have it automatically look for 'image.gif', 'image.jpg',
and 'image.png' if 'image' doesn't exist.  (The administrator
would be able to define the list of extensions to be searched.)

That seems a lot nicer than

    (:if attachexists Profiles/Pm/image.png:)Attach:Profiles/Pm/image.png
    (:elseif attachexists Profiles/Pm/image.jpg:)Attach:Profiles/Pm/image.jpg
    (:elseif attachexists Profiles/Pm/image.gif:)Attach:Profiles/Pm/image.gif
    (:if:)

OTOH, it's not clear what to do in the case where none of the
images exist -- we don't want to create an upload link for 'image'
without an extension.

Pm



More information about the pmwiki-users mailing list