Login Register


Rotating Image Script filter_list
Author
Message
Rotating Image Script #1
This script will randomly pick an image from a folder on your website.
Every time you refresh the page, a different image will pop up.


Instructions:

1. Copy & paste the code I'll provide below into Notepad or Notepad++ if you have it downloaded. Save it and name it 'index.php'.

2. Go into your FTP and create a folder called 'rotate.jpeg'.

3. Take your 'index.php' file and upload it into the 'rotate.jpeg' folder.

4. Upload as many images as you want into the same folder. Remember, all the images that are included in this folder will be the ones rotating

5. You're done. Go to http://yourdomainname.com/rotate.jpeg and keep refreshing to make sure it's working.

5.1. If you want to specify a specific image, type the image name after you type in /rotate.jpeg/

e.g. http://yourdomainname.com/rotate/jpeg/sanctuary

It'll pop up the specific image with the name 'sanctuary'.

Also, if you want to use this for your avatar on a forum site (like I am right now), go into the UserCP > Change Avatar.

Where it says 'Avatar URL', copy & paste the url for the rotating image page from your site. It should work.

If you want to use it for your signature, go into the UserCP > Change Signature.
Type in [img]http://YourDomainName.com/rotate.jpeg/[ /img]. Remove the space between in the [img] closing tag.
Save and you're done.

Enjoy!


PHP Code:
<?php $folder = '.'; $extList = array(); $extList['gif'] = 'image/gif'; $extList['jpg'] = 'image/jpeg'; $extList['jpeg'] = 'image/jpeg'; $extList['png'] = 'image/png'; $img = null; if (substr($folder,-1) != '/') { $folder = $folder.'/'; } if (isset($_GET['img'])) { $imageInfo = pathinfo($_GET['img']); if ( isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) && file_exists( $folder.$imageInfo['basename'] ) ) { $img = $folder.$imageInfo['basename']; } } else { $fileList = array(); $handle = opendir($folder); while ( false !== ( $file = readdir($handle) ) ) { $file_info = pathinfo($file); if ( isset( $extList[ strtolower( $file_info['extension'] ) ] ) ) { $fileList[] = $file; } } closedir($handle); if (count($fileList) > 0) { $imageNumber = time() % count($fileList); $img = $folder.$fileList[$imageNumber]; } } if ($img!=null) { $imageInfo = pathinfo($img); $contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ]; header ($contentType); readfile($img); } else { if ( function_exists('imagecreate') ) { header ("Content-type: image/png"); $im = @imagecreate (100, 100) or die ("Cannot initialize new GD image stream"); $background_color = imagecolorallocate ($im, 255, 255, 255); $text_color = imagecolorallocate ($im, 0,0,0); imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color); imagepng ($im); imagedestroy($im); } } ?>

Credit goes to Ocean/Mxlitary for originally making this tutorial. I'm just bringing it onto the new UG.

Reply

RE: Rotating Image Script #2
Very nice and HQ thread KiU

Reply

RE: Rotating Image Script #3
Nice thread Sanc, keep these HQ threads comming.
[Image: U2JKI5T.png]

Reply

RE: Rotating Image Script #4
Thanks for this tutorial, Sanc! Many users will enjoy this.

Reply

RE: Rotating Image Script #5
(11-11-2012, 12:47 AM)Blur Wrote: Thanks for this tutorial, Sanc! Many users will enjoy this.

Slyestcat is a copycat. He copied my avatar idea. Sad

Reply







Users browsing this thread: