TinyPortal

Development => Block Codes => Topic started by: akulion on May 03, 2006, 02:09:08 AM

Title: [Block] Random Image Rotator [PHP]
Post by: akulion on May 03, 2006, 02:09:08 AM
Hi

Nothing much to it...

1. Create a directory on your server anywhere you want

2. Download this file (rightclick and save as) (http://path-to-peace.net/misc/rotate.zip)

3. Unzip and Upload the file you downloaded to your directory

4. Upload the images to the same directory - dosent matter what their names or format or size or dimensions are...as long as its a png, gif or jpg file

5. add this code to a SCRIPT / HTML block



<img src="http://www.mysite.com/myfolder/rotate.php" alt="A Random Image" />



Be sure to change www.mysite.com/myfolder to your website addy and folder path!

Each time your page loads it will display a random image from your folder :)
And thats all - enjoy :)

Details of how this thing works and its homepage can be found HERE (http://automaticlabs.com/products/rotator)
Title: Re: Random Image Rotator [PHP]
Post by: Uthn on May 03, 2006, 12:16:24 PM
Thanks a lot, this one works fine for me !  ;D

(was having a fight with the one from this topic : http://www.tinyportal.net/smf/index.php?topic=4220.0 (http://www.tinyportal.net/smf/index.php?topic=4220.0)
Title: Re: Random Image Rotator [PHP]
Post by: Mitchâ„¢ on May 03, 2006, 12:59:33 PM
Quote from: Uthn on May 03, 2006, 12:16:24 PM
Thanks a lot, this one works fine for me !  ;D

(was having a fight with the one from this topic : http://www.tinyportal.net/smf/index.php?topic=4220.0 (http://www.tinyportal.net/smf/index.php?topic=4220.0)

I am sorry that you didnt find it to your needing.
Title: Re: Random Image Rotator [PHP]
Post by: HappyFace on May 03, 2006, 01:59:51 PM
How do i add the code to a script/block?
Title: Re: Random Image Rotator [PHP]
Post by: akulion on May 03, 2006, 02:41:25 PM
You must be logged in as Admin

Click on Manage blocks ---> Add Center Block ---> scriptbox + Send

Put the script in the box that appears and press send and then activate your block
Title: Re: Random Image Rotator [PHP]
Post by: HappyFace on May 03, 2006, 02:43:19 PM
Quote from: akulion on May 03, 2006, 02:41:25 PM
You must be logged in as Admin

Click on Manage blocks ---> Add Center Block ---> scriptbox + Send

Put the script in the box that appears and press send and then activate your block

I only have this:

TinyPortal
Settings
Blocks
Articles
Downloads Manager
Title: Re: Random Image Rotator [PHP]
Post by: akulion on May 03, 2006, 02:45:56 PM
Ok then click on blocks :) it should be there - since the version im using says "manage blocks" so maybe in your version it just says "blocks"

Try it
Title: Re: Random Image Rotator [PHP]
Post by: HappyFace on May 03, 2006, 03:13:17 PM
I have " Add MenuItem  " but no center block.. im using the latest TPortal as far as i know.
www.happyserver.be
Title: Re: Random Image Rotator [PHP]
Post by: G6Cad on May 03, 2006, 03:23:56 PM
You have to activate the center bar.

Admin/tinyportal/settings/check the catbox (use centerbar)
Title: Re: Random Image Rotator [PHP]
Post by: technodragon73 on May 03, 2006, 03:41:15 PM
is there a way to set a maximum size for this?  I want to use it to show random images from my gallery but some of them are pretty big so i want to put a "cap" on the size so they don't explode my forum...lol
Title: Re: Random Image Rotator [PHP]
Post by: akulion on May 03, 2006, 03:52:30 PM
yes its very simple.....

the tag



<img src="http://www.mysite.com/myfolder/rotate.php" alt="A Random Image" />



Simply add to it the width and height attributes like so and set according to ur needs



<img src="http://www.mysite.com/myfolder/rotate.php" alt="A Random Image" / height=120 width=100>

Title: Re: Random Image Rotator [PHP]
Post by: technodragon73 on May 03, 2006, 04:25:11 PM
Quote from: akulion on May 03, 2006, 03:52:30 PM
yes its very simple.....

the tag



<img src="http://www.mysite.com/myfolder/rotate.php" alt="A Random Image" />



Simply add to it the width and height attributes like so and set according to ur needs



<img src="http://www.mysite.com/myfolder/rotate.php" alt="A Random Image" / height=120 width=100>



Cool, wasn't sure if that would work...now I am realtively new to html, is there a way to make those values relative rather than absolute?  Reason I ask is if i make it absolute and the image is sized landscape then the widht and height would distort it.
Title: Re: Random Image Rotator [PHP]
Post by: akulion on May 03, 2006, 04:37:29 PM
well u could try using percentages like width = 50% height =50%

but apart from that i dont know any other way
Title: Re: Random Image Rotator [PHP]
Post by: Uthn on May 03, 2006, 04:59:12 PM
Quote from: Mitchâââ,¬Å¾Ã,¢ on May 03, 2006, 12:59:33 PM
Quote from: Uthn on May 03, 2006, 12:16:24 PM
Thanks a lot, this one works fine for me !  ;D

(was having a fight with the one from this topic : http://www.tinyportal.net/smf/index.php?topic=4220.0 (http://www.tinyportal.net/smf/index.php?topic=4220.0)

I am sorry that you didnt find it to your needing.

Sorry Mitch, wasn't refering to your script but to sdl's one; which is in the same thread. Didn't meant to hurt ;)
Title: Re: Random Image Rotator [PHP]
Post by: technodragon73 on May 03, 2006, 06:50:01 PM
the 50% trick does it...it works nicely!
Title: Re: Random Image Rotator [PHP]
Post by: rbh on May 15, 2006, 01:31:33 AM
i am using this script for avatars and it works except it resizes my avatars to 150x150 when they are only 95x95. anyone else try it for avatars and having this problem?
Title: Re: Random Image Rotator [PHP]
Post by: akulion on May 15, 2006, 06:01:25 AM
Quote from: akulion on May 03, 2006, 03:52:30 PM
yes its very simple.....

the tag



<img src="http://www.mysite.com/myfolder/rotate.php" alt="A Random Image" />



Simply add to it the width and height attributes like so and set according to ur needs



<img src="http://www.mysite.com/myfolder/rotate.php" alt="A Random Image" / height=120 width=100>



rbh try doing that...and furthermore if you have lots of images of varying sizes (dimensions) use width=100% height=100% and it should adjust accordingly :)
Title: Re: Random Image Rotator [PHP]
Post by: copter on May 20, 2006, 12:17:54 PM
Hi! I am using the random image thingy in a block, and I've put the rotate.php file in one of the avatar folders; and it works - but would there be any side affects or will it cause damage to the forum - you know code wise etc.
Title: Re: Random Image Rotator [PHP]
Post by: Techdomain on May 21, 2006, 12:22:48 AM
that will work fine - you can put that file in any folder with images. I dont know how it will go with folders that have files other than images though!

another way to make the size relative (instead of using 50% or whatever) - you dont have to put height and width. So for my forums, I just use width="190" so it fits in the side bar nicely.
Title: Re: Random Image Rotator [PHP]
Post by: akulion on May 21, 2006, 01:17:00 AM
Side effects?

Well in versions lower than TP 0.8.6 it has been known to cause a slight cough and wheesing in the forum

And in 0.8.6 only one reported case of a slight redness around the "home" button was reported

apart from that there are no other reported side effects  :2funny:
Title: Re: Random Image Rotator [PHP]
Post by: Techdomain on May 21, 2006, 03:54:32 AM
soreness of the finger from clicking refresh? would that be a side effect?
Title: Re: Random Image Rotator [PHP]
Post by: copter on May 21, 2006, 02:33:28 PM
lool so far so good it seems to work :)
Title: Re: Random Image Rotator [PHP]
Post by: asora on July 01, 2006, 12:38:35 AM
work fine, thank !

i use an a href tag like this to open an imge file,

<a href="http://www.yoursite.com/image/rotate.php" target="_blank"><img src="http:///www.yoursite.com/image/rotate.php" alt="A Random Image" / height=100 width=120></a>

But i can't get the tham image...
If any one can helf to open an image file in iframe ?
thank.

I hope you can andertsand what i mean...
english is not my coffee cup.
Title: Re: Random Image Rotator [PHP]
Post by: akulion on July 01, 2006, 01:20:30 AM
I dont think that can be linked to show the same image

Why?

Because rotate.php is a file which randomly picks up an image from the directory and displays it....so on every reload of the script the image path is different, So linking to it like that wont work

Unfortunately I dont think its possible unless the PHP file itself was modified to nclude a function to add links to the images

Title: Re: Random Image Rotator [PHP]
Post by: asora on July 02, 2006, 10:51:41 PM
thank akulion, i think the mod like "image in a block" from enigma.
Title: Re: Random Image Rotator [PHP]
Post by: GM on July 14, 2006, 11:03:20 PM
I like this little script,works good and is simple to use for an average Joe. How hard would it be to have it randomly rotate without needing to reload or refresh the page?
Title: Re: Random Image Rotator [PHP]
Post by: akulion on July 17, 2006, 10:39:32 PM
im not too sure but i think with AJAX it can be done...but then again i dont know much about AJAX
Title: Re: Random Image Rotator [PHP]
Post by: Polymath on August 14, 2006, 11:08:49 AM
Well. I came here and in the search box I put 'random'  And from that I got this.

Thanks akulion. Its exactly what Im after
Title: Re: Random Image Rotator [PHP]
Post by: akulion on August 17, 2006, 12:59:29 AM
ur welcome :D
Title: Re: Random Image Rotator [PHP]
Post by: nosgr on August 19, 2006, 07:51:04 AM
which script i have to paste in the block manager to see it in a block?

All the contents of rotate.php?
Title: Re: Random Image Rotator [PHP]
Post by: akulion on August 19, 2006, 08:38:48 AM
no just the one line in the 1st post

this one:


<img src="http://www.mysite.com/myfolder/rotate.php" alt="A Random Image" />



be sure to change the address in there for your site ok
Title: Re: Random Image Rotator [PHP]
Post by: nosgr on August 19, 2006, 08:45:56 AM
OK, thanks it works wonderfully ;)
Title: Re: Random Image Rotator [PHP]
Post by: akulion on August 19, 2006, 08:47:06 AM
ur welcome
Title: Re: Random Image Rotator [PHP]
Post by: Polymath on August 19, 2006, 10:06:59 AM
nosgr, I made a folder called 'rotate' uploaded to that rotate.php and the images.

In the html block put


<img src="http://www.yoursite.com/rotate/rotate.php" alt=" Random Image" />

Title: Re: Random Image Rotator [PHP]
Post by: Ronlx2 on November 09, 2006, 01:02:35 PM
Wanted to say thanks it works great.
Title: Re: Random Image Rotator [PHP]
Post by: than on November 11, 2006, 11:01:48 PM
Hi,

I’m using this block, and works perfect, but i have a "problem" with this. I use this to show a gallery random image, but the gallery folder contains thumbs too. I need a modification that allows me to exclude images with characters *thumb* in name field.

Please help me
Title: Re: Random Image Rotator [PHP]
Post by: Techdomain on November 12, 2006, 08:56:57 AM
maybe easiest way is to seperate them?
Title: Re: Random Image Rotator [PHP]
Post by: than on November 12, 2006, 10:47:41 AM
SMF Gallery Lite, does not support different locations for thumbs and images.
Title: Re: Random Image Rotator [PHP]
Post by: Techdomain on November 12, 2006, 10:45:17 PM
Yes.. but what I am saying is that it might be easiest for a small gallery to make a seperate folder, and copy the files you want rotated into that, and run rotate.php from it. If your gallery is huge, with hundreds of files added daily, then you might have to think of another solution aka coppermine or a custom one.
Title: Re: Random Image Rotator [PHP]
Post by: than on November 12, 2006, 10:50:01 PM
I donÂÃ,´t know php, but sure is really easy and only require a few lines of code for make an text exclusion.

Title: Re: Random Image Rotator [PHP]
Post by: Techdomain on November 12, 2006, 11:14:46 PM
Are they both the same image type? or are thumbs all a different format (eg GIF) then the gallery images?
Title: Re: Random Image Rotator [PHP]
Post by: than on November 13, 2006, 07:38:02 AM
All images have jpg format.

Example:

Image 1= 1_08_11_06_1_11_21.jpg
Thumb 1= thumb_1_08_11_06_1_11_21.jpg
Title: Re: Random Image Rotator [PHP]
Post by: Reality12 on March 23, 2007, 07:40:35 PM
this is an awesome script! did exactly what i needed. thank you!
Title: Re: Random Image Rotator [PHP]
Post by: Ry Perd on April 20, 2007, 10:55:01 AM
Thank you, did exactly what i needed it to do  :up:
Title: Re: Random Image Rotator [PHP]
Post by: spurry on January 14, 2008, 10:54:06 PM
Quote from: than on November 13, 2006, 07:38:02 AM
All images have jpg format.

Example:

Image 1= 1_08_11_06_1_11_21.jpg
Thumb 1= thumb_1_08_11_06_1_11_21.jpg

same here is there any eay around this?
Title: Re: Random Image Rotator [PHP]
Post by: nasir on March 25, 2009, 08:10:07 PM
Is there any way to increase the speed of the rotation.in my site the image does not get changed until i click and go to other page..I want an constant slide show,,,,how can i do that ?? pls  tell me

SMF 1.1.8
Tp 1.0.5
Title: Re: Random Image Rotator [PHP]
Post by: IchBin on March 25, 2009, 08:16:05 PM
The easiest way would be to make your images an animated .gif that does it all for you.
Title: Re: Random Image Rotator [PHP]
Post by: ZarPrime on March 25, 2009, 08:21:01 PM
Quote from: nasir on March 25, 2009, 08:10:07 PM
Is there any way to increase the speed of the rotation.in my site the image does not get changed until i click and go to other page..I want an constant slide show,,,,how can i do that ?? pls  tell me

SMF 1.1.8
Tp 1.0.5

That's not what this code snippet does.  From the first post in this topic ...

Quote from: akubear on May 03, 2006, 02:09:08 AM
Each time your page loads it will display a random image from your folder :)
And thats all - enjoy :)

If you want a slideshow script, you'll have to keep searching.

ZarPrime
Title: Re: Random Image Rotator [PHP]
Post by: Ianedres on March 26, 2009, 06:01:01 AM
Being that it is php-based, you could use a meta refresh tag in an IFRAME to time the loading of the script's image...  that would be a kludge, at best, to use this script to load over and over.

You would be better served using a Javascript slideshow, which as ZarPrime suggested, you could search and find one to your liking.
Title: Re: Random Image Rotator [PHP]
Post by: Eddy Matthews on May 10, 2009, 10:54:09 PM
This works perfectly, but one thing I'd like to add is to display the filename that is being shown - Is this possible?

Regards
Eddy
Title: Re: Random Image Rotator [PHP]
Post by: JPDeni on May 10, 2009, 11:19:04 PM
Probably. If you're using the code from the first post in this topic, you'd have to alter the rotate.php file, which I haven't looked at, so I couldn't tell you what to change. If you're using some other code, please post it.
Title: Re: Random Image Rotator [PHP]
Post by: Eddy Matthews on May 11, 2009, 12:01:50 AM
Quote from: JPDeni on May 10, 2009, 11:19:04 PM
Probably. If you're using the code from the first post in this topic, you'd have to alter the rotate.php file, which I haven't looked at, so I couldn't tell you what to change. If you're using some other code, please post it.

I'm using the code from the first post, but my knowledge of php coding is none-existant, so any help would be appreciated.

Regards
Eddy
Title: Re: Random Image Rotator [PHP]
Post by: JPDeni on May 11, 2009, 01:19:01 AM
Actually, I can't see how you could use that script and print out the name of the file. There's really no place to do it.
Title: Re: Random Image Rotator [PHP]
Post by: IchBin on May 11, 2009, 10:40:33 PM
It would seem the file sends all the info to the output buffer. Which I'll admit that I don't know anything about. lol However, I don't see any reason why we can't try something. :D At the end of the file you'll see this code.
if ($img!=null) {
$imageInfo = pathinfo($img);
$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
header ($contentType);
readfile($img);


Right after the readfile() line, lets add an echo and see if we can get it to output the filename.

echo $imageinfo['basename'];

Haven't tested it myself, but I do know how pathinfo works, so I'm hoping that will output the filename. Let me know if it works for you.
Title: Re: Random Image Rotator [PHP]
Post by: JPDeni on May 12, 2009, 01:05:21 AM
The problem is that there's no echo in the script at all. If it just would echo the img src tag, then echoing the name of the file, too would be a piece of cake. (I really hate external php files anyway. Really hate them a whole lot. But that's my problem. :) )