We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15001
    • 697 Posts
    Hi,

    For some site, I must display 3 small images randomly on all pages.
    All images can be stored in a unique folder.

    I saw that ImageGallery has some parameter named &order_by
    which accepts the "random" value.

    I also found this snippet : http://modxcms.com/forums/index.php?topic=34923.0

    Does someone have some experience in picking pictures randomly ?
    Should I use ImageGallery for this ?

    Thanks.
      • 10226
      • 412 Posts
      I do... let me see what I did.

      ok this site was for selling parrots and I had a sidebar item that grabbed a random baby that was not sold or reserved...

      [[Ditto? &tpl=`baby_sb` &parents=`7` &randomize=`1` &display=`1` &filter=`reserved,1,2` ]]

      and the tpl

      <img class="bpx80" src="{{img_path_baby}}th_[+babypic+]" alt="[+baby_type+]" width="80" height="80"/><p><a href="[~7~]" title="[+baby_type+]">Have a look at this sweet little [+baby_type+] and our other babies available for sale.</a></p>
      <hr/>

      so how were the baby pics stored?

      as a TV on the page for that baby...

      IMG_1419.jpg

      so I guess this is not much help to you. all of the thumbnails were made with a photoshop script before we uploaded them.

      hope this can help someone lol!
        • 15001
        • 697 Posts
        Thanks, but unfortunately this is not what I want.

        In fact, this is for a site that currently is static and each page display 3 thumbnails. Which thumbnail is shown is not meaningful regarding the topics.

        My first idea was to use 3 image TV, but I had to set them manually.
        In order to reduce costs, I thought picking the 3 images randomly.

        I hope that MagicGallery or something else can do the job.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          A snippet to randomly grab three images from a folder isn’t difficult, if you’re willing to go to the trouble of coding for the non-duplication of the selections! Maybe put the image filenames into an array, randomly grab one and remove it from the array, and repeat twice more.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org