Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6673241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:36:15+00:00 2026-05-26T03:36:15+00:00

I have this drupal slideshow which pulls images from a folder sequentially by image

  • 0

I have this drupal slideshow which pulls images from a folder sequentially by image title (01_title.jpg, 02_title.jpg, etc..)

I was wondering if there is an easy way to randomize the images, so it starts with a different image every time you refresh the page?

you can view the slideshow here http://www.rubensteinpr.com/

Thanks!

<div id ="index">
        <?php
            // Note that !== did not exist until 4.0.0-RC2
            $desired_extension = 'jpg'; //extension we're looking for 
            $banner_imgs_array = array(); // array of banner images
            $banner_imgs = ''; // sting of banner images names comma dileneated

            if ($handle = opendir(file_directory_path().'/banner_imgs')) {

                /* This is the correct way to loop over the directory. */
                while (false !== ($file = readdir($handle))) {
                    if(($file != ".") and ($file != "..")) { 
                      $fileChunks = explode(".", $file); 
                      if($fileChunks[1] == $desired_extension) //interested in second chunk only 
                      {       
                        $banner_imgs_array[] = $file;
                      } 
                    } 
                }

                closedir($handle);

                $banner_imgs = implode(',', $banner_imgs_array);
            }
        ?>
        <div id="banner"><img src="<?php print file_directory_path(); ?>/temp_banner.jpg" width="702" height="310" border="0"></div>
        <div id="bannerText">media relations &bull; strategic planning &bull; digital communications &bull; crisis management</div>
        <script type="text/javascript">
            // <![CDATA[

            var so = new SWFObject("<?php print file_directory_path(); ?>/banner.swf", "ban", "702", "310", "8", "#ffffff");
            so.addParam('menu', 'false');
            so.addParam("wmode", "transparent");
            so.addParam("base", "<?php print file_directory_path(); ?>");
            so.addVariable("banner_imgs", "<?php print $banner_imgs; ?>");
            so.write("banner");

            // ]]>
        </script>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:36:16+00:00Added an answer on May 26, 2026 at 3:36 am

    adding

    shuffle($banner_imgs_array);
    

    line just before

    $banner_imgs = implode(',', $banner_imgs_array);
    

    should do the trick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this basic Drupal scenario and question: I have a form which accepts
I have this HTML from Drupal <span id=terms style=visibility:hidden> <ul class=links inline> <li class=taxonomy_term_14
I have this website iloveforwards.com created using drupal. I would like to have a
I have a Drupal setup like this: Content type: Apartments Vocabulary: Areas , that
I have this drupal website that revolves around a document database. By design you
I have this group of radio buttons in which each of individual button has
Drupal 6.x I have this module that manages four different content types. For that
I have this schema which I need to define two primary keys; one is
I have a web site. This is a drupal site using PostgreSQL database.In this
I have a View which is a series of images. I need the output

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.