Jump to content

Recommended Posts

Thanks both... yes, the homepage image rotation needs attention but I confess I don't know anything about javascript so it was a struggle just getting to that bit. I see istockphoto.com has a random selector and might have a look at how they did it.

 

What do you mean, "search feature outside of each category" ? Do you mean it would be better to be able to search on both dropdowns at once?

 

Thanks for your feedback :)

The site looks great.

 

FYI....you can do the image rotation with PHP.

 

<?php

$img_array = array('add','arrow','book','cancel','contact');
$random_img = $img_array[rand(0, count($img_array) - 1)];
echo '<img src="images/'.$random_img.'.gif" class="noBorder" alt="Random Image"/>';

?>

 

per the above code, you'd have to have images named "image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg", "image5.jpg" in your "images" directory.  You can add more or remove some, just make sure that the list in array matches the images that you have in your "images" directory

You could even make it more dynamic so it read the files in the directory and chose a random one....

 

This could get resource intensive causing delays, but you could catalog the files or surely theres some way to just count files in a folder, thus allowing you to select a random number < the amount of pictures.

In the code I put above, I used .gif in the code, but told you to use .jpg in the explanation.  Just change the one line to the red below.

 

echo '<img src="images/'.$random_img.'.jpg" class="noBorder" alt="Random Image"/>';

 

corbin's suggestion would be ideal, since you'd be able to just add a new image or remove an image whenever you wanted without having to change the array values.  I went for the simpler (coding wise) approach, because I'm lazy.  ;D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.