![]() |
Simple image rotation script
Been looking all over for this. But all i see is script rotating 1 image.
i've got about a 100 images. I want to display for example 5 of these images randomly every page load (without doubles). If some images get repeated onload it doesnt matter, as long as there aren't doubles in every row of 5. All the pics need to link to a unique url too. Suggestions? |
WOJ has a simple script that will do exactly that.
|
Option 1: http://ma.tt/scripts/randomimage/
Option 2: http://randaclay.com/tips-tools/mult...ge-php-script/ Option 3: Code:
<?php |
Quote:
|
Assuming that all image URL's are stored in "images.txt" (one URL per line), the code will be as simple as this:
Code:
$images = file('images.txt'); |
Quote:
Code:
$img_src = end(explode("/", $img)); I have added some lines to assign imagename to the url for each pic like i was planning to: Code:
$img_src = end(explode("/", $img)); |
you mind posting the entire edited code? :)
thanks |
Quote:
|
one thing i noticed. About the above code.
When you have your scriptcode.php in the same folder as the images, the rotator sometimes grabs the .php file too. When i put the scriptcode.php in a parent folder: /mysite/script/scriptcode.php And the images in: /mysite/script/images/image.jpg The script looks for the images in /mysite/script/ like it doesn't see the images folder. I have put the correct image path in the script. Think it has something to do with the explode code? |
fixed the above by just adding images dir before the img src output.
Quote:
script is at: mysite.com/script/script.php Images in: mysite.com/script/images/ Code: Code:
<?php |
nvm ..... read the image part
|
Neat code to have. Thanks!
|
All times are GMT -7. The time now is 01:46 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123