[pmwiki-users] show random image

Patrick R. Michaud pmichaud at pobox.com
Thu Nov 22 09:30:18 CST 2007


On Thu, Nov 22, 2007 at 11:27:44AM +0000, Hans wrote:
> I cannot find one, so I like to ask:
> Is there a recipe for showing a random image from a selection of
> images, so every time a page gets loaded, a random image is shown?
> 
> Some solution was mentioned in the past, but I forgot.

I highly recommend the RandomQuote recipe.  With it, one
simply creates a page of images (call it "ImageIndex"):

    [[#image1]]
    Attach:image1.jpg
    [[#image2]]
    Attach:image2.jpg
    [[#image3]]
    Attach:image3.jpg

and then do

    (:include {ImageIndex$RandomSection} :)

to grab an image at random from the page.

Of course, any wiki markup can go into the individual sections,
not just Attach: links.  In particular, this makes it easy to
set it up so that each random image is itself a link to a
different target.

    [[#image1]]
    [[http://www.pmwiki.org/ | Attach:image1.jpg]]
    [[#image2]]
    [[http://www.example.com/ | Attach:image2.jpg]]
    [[#image3]]
    [[http://www.wikipedia.org/wiki/PmWiki | Attach:image3.jpg]]

Pm



More information about the pmwiki-users mailing list