Results 1 to 5 of 5

Thread: Randomize a collage

  1. #1
    Join Date
    Feb 2008
    Posts
    7
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Randomize a collage

    I have volunteered to webmaster a school site. I have created a collage with 6 images across the top on the main page. Is there a script that will randomly select 6 different images for the collage each time you load? I would like it so each time a parent visits they see different images. I also hope this will help with load time - we have primarily dial up customers here!! I do not want any slide show going on because of the speed issue. I hope this is possible, I just can't find the script.
    Thank You

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    are you storing your images in an array? or have you just hard-coded them in? are they in a database?

    if you hard coded them than you would need to either put them into an array or a database. If they are in a database I am assuming you are grabbing them out somehow, so instead of parsing them directly to the page, put them into an array

    if you are using an array you can randomize the order of the array, then take the first X number items in the array and parse it to your page, creating your random images.

    the load time of the images is all dependent on the size and dpi (resolution) of the images. generally the larger the image in size and/or resolution, the longer it will take to display on the page.

    If you are having difficulties with load time, try to use other image formats...
    gif / jpg formats are usually the premier choice for image files.

  3. #3
    Join Date
    Feb 2008
    Posts
    7
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    I am storing the images in a seperate folder named collage. The folder has all the images the same size so the script can randomly choose any image for any position.
    Speed isn't a concern for the size of the collage (800 x 75 pixels). I just don't want a script that needs to download images while being viewed or before being viewed. We plan on having several images to choose from.
    The scripts I have seen call on all of the images to download before the page loads, or to download new images in a slide show. (not what I want).
    I want the script to select only 6 images at a time to display in the collage.
    Thank you for replying so fast

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by jhogle View Post
    I just don't want a script that needs to download images while being viewed or before being viewed.
    ...
    The scripts I have seen call on all of the images to download before the page loads, or to download new images in a slide show.
    that is a contradiction... the images cannot just appear out of no where. they will have to be downloaded at some point, however once they are downloaded they will be cached (stored) on the users local hard-drive so the next time that image is accessed, the server will use the cached version of the image, thus saving load time. The previous statement assumes the user doesn't clear his/her temporary files and that you, the developer, does not set a meta tag preventing caching.

    So, sadly, you will need to pick whether you want the images to load before the page displays, or if you would like the images and the page to load at the same time. If you wanted a slideshow, I would suggest the former, however since you are just displaying the images, I would actually suggest the latter. This would allow the user to see the other contents of the page, and as the images download they will become viewable. The former would pre-load the images which is ideal for a slideshow because it forces all of the images to download and be put into position, thus making sure that there are no "holes" in the show presentation.

    Now as for grabbing the images, I do not believe this is possible with Javascript alone, which is why I was suggesting using an array of images. The images aren't actually stored in the array, but rather a reference url is stored. This url points to the location in that folder and upon loading the page, the array can be manipulated so 6 "random" images are chosen. Only the 6 images that are picked will be downloaded / cached. the remaining images in the array will just sit there waiting for the user to hit refresh or for another browser to access the page, at which point they will have the chance at being one of the chosen 6.
    Last edited by boogyman; 02-26-2008 at 02:03 PM. Reason: typos / explain a term more in depth

  5. #5
    Join Date
    Feb 2008
    Posts
    7
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    I will research this. Thank You!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •