Looking for a random image script in PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ad-Min
    Confirmed User
    • Feb 2010
    • 655

    #1

    Looking for a random image script in PHP

    Hi guys,i am looking for a random image script in php.
    I´ve checked many sites but i am not able to find what i am looking for.
    I would like to rotate a couple of thumbs from a folder randomly.
    I have about 20 folders and all the thumbs should go on one page.
    Actualy 20 rotating thumbs on the page (20 folders x 5 thumbs per folder).
    No java for now,i need it in php.
    Any suggestions?

    Thanks in advance
  • newB
    Confirmed User
    • Jul 2006
    • 2870

    #2
    Here's one I used to make a fake TGP a long time back and it worked like a charm in that it allows for link attributes. If you don't want to link the images, just leave the fields blank in the ini sheet.

    http://www.alistapart.com/articles/betterrotator/

    The best Adult Affiliate Programs reviewed and indexed by niche and feature.
    Easily find the sponsors that suit your needs.


    Comment

    • Supz
      Arthur Flegenheimer
      • Jul 2006
      • 11057

      #3
      Take a look at AIRS from BigDotMedia

      http://www.bigdotmedia.com/airs.php

      Comment

      • garce
        Confirmed User
        • Oct 2001
        • 7103

        #4
        You can try this is you just want something simple: http://ma.tt/scripts/randomimage/

        Comment

        • HomerSimpson
          Too lazy to set a custom title
          • Sep 2005
          • 13826

          #5
          rstgp or contact me to write you something custom

          www.awmzone.com/services
          Make a bank with Chaturbate - the best selling webcam program
          Ads that can't be block with AdBlockers !!! /// Best paying popup program (Bitcoin payouts) !!!

          PHP, MySql, Smarty, CodeIgniter, Laravel, WordPress, NATS... fixing stuff, server migrations & optimizations... My ICQ: 27429884 | Email:

          Comment

          • fris
            Too lazy to set a custom title
            • Aug 2002
            • 55679

            #6
            Originally posted by newB
            Here's one I used to make a fake TGP a long time back and it worked like a charm in that it allows for link attributes. If you don't want to link the images, just leave the fields blank in the ini sheet.

            http://www.alistapart.com/articles/betterrotator/
            i would use this, but a modified version so you dont have repeating images.

            http://randaclay.com/tips-tools/mult...ge-php-script/
            Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

            Comment

            • Ad-Min
              Confirmed User
              • Feb 2010
              • 655

              #7
              Thanks a lot guys ,i would rep you all but i am not able !

              Comment

              • SmellyNose
                Confirmed User
                • Aug 2009
                • 206

                #8
                I wrote this in the GFY quick reply box, so who knows if it has errors.
                Code:
                <?php
                define('BASE_DIR', '/var/www/mysite/images/'); // Where are your images?
                define('IMAGE_LIMIT', 10); // how many images to show?
                
                $files     = glob(BASE_DIR.'*');
                $images = Array();
                
                if(empty($files)) {
                    die("Hey, dude, there are no files. What happened?");
                }
                
                foreach($files as $v) {
                    if(is_dir($v)) {
                        foreach($files as $v) { // This should be a function which can loop through further sub directories if needed
                            //get exif image type, if it's an image append to array
                            $images[] = $v;
                        }
                    } else {
                        $images[] = $v;
                    }
                }
                
                shuffle($images); // Randomise the array
                for($i=0;$i<IMAGE_LIMIT;$i++) {
                    $img = $images[$i];
                    if(empty($img)) {
                        break; // Might be best doing a foreach above whilst keeping $i as a loop counter and breaking the loop once you reach the limit
                    }
                    $img_src = end(explode("/", $img));
                    echo "<img src='{$img_src}'/>";
                }
                I'm a PHP developer - 594086663 - [email protected]

                Comment

                • Ad-Min
                  Confirmed User
                  • Feb 2010
                  • 655

                  #9
                  Originally posted by SmellyNose
                  I wrote this in the GFY quick reply box, so who knows if it has errors.
                  Code:
                  <?php
                  define('BASE_DIR', '/var/www/mysite/images/'); // Where are your images?
                  define('IMAGE_LIMIT', 10); // how many images to show?
                  
                  $files     = glob(BASE_DIR.'*');
                  $images = Array();
                  
                  if(empty($files)) {
                      die("Hey, dude, there are no files. What happened?");
                  }
                  
                  foreach($files as $v) {
                      if(is_dir($v)) {
                          foreach($files as $v) { // This should be a function which can loop through further sub directories if needed
                              //get exif image type, if it's an image append to array
                              $images[] = $v;
                          }
                      } else {
                          $images[] = $v;
                      }
                  }
                  
                  shuffle($images); // Randomise the array
                  for($i=0;$i<IMAGE_LIMIT;$i++) {
                      $img = $images[$i];
                      if(empty($img)) {
                          break; // Might be best doing a foreach above whilst keeping $i as a loop counter and breaking the loop once you reach the limit
                      }
                      $img_src = end(explode("/", $img));
                      echo "<img src='{$img_src}'/>";
                  }
                  Thanks but i have solved the problem already.

                  Comment

                  Working...