Virtual University Design and Technology, ANGEL Tips & Techniques
Previous Page
Next Page

Random Images

Random images are just used to produce random images for each page. This can help keep students interested in the page, instead of the same dull images on each page.

  1. Prepare your image files.
    • Make sure they all have the same width and height if you are including the width and height in your code (it is good practice to do this).
    • Name your files sequentially, starting with either 001.jpg or 001.gif, depending on whether you are using gifs or jpegs. For example, if I am using .jpg files and I have five of them, they should be named 001.jpg, 002.jpg, 003.jpg, 004.jpg and 005.jpg.
    • Create a folder for the files in the associated files manager in ANGEL and upload them there.
  2. Copy and paste this code to the top of the page you want the random pictures to show up

    <script src='/msu_jscript/random_images.js'></script>
  3. Note: You can download the script if you'd like to view the source.

  4. Copy and paste this code where you want the picture and modify the bold parts according to your needs.

    <script>
    random_images('number of images', 'alignment of the image', 'the folder where the images are', 'the alt tag', 'width of the image', 'height of the image', 'border size', 'the extension of the image');
    </script>

    For example, if you want a random image from a group of ten images, with the image being aligned right, 100x200 pixels, with no border and all of the pictures being jpegs with .jpg file extensions and your images being located in a folder called "random_images" in the associated files manager at the Lessons level, your code would look like the following:

    <script>
    random_images('10', 'right', './random_images', ' ', '100', '200', '0', '.jpg');
    </script>

    Note: Be sure that the "Page Format" of the page where you are including the random images is set to HTML Text.

Previous Page
Next Page

Last updated: August 16, 2007
This website is maintained by vuDAT
Copyright © 2008 Michigan State University Board of Trustees
MSU is an affirmative-action, equal-opportunity employer. East Lansing, MI 48824 USA
Michigan State University