Background Randomizer?
4 posters
Page 1 of 1
Background Randomizer?
Is there a way to make it so a different background image displays every time the page is loaded?
Any help or suggestions are appreciated! Thanks~
-Clover
Any help or suggestions are appreciated! Thanks~
-Clover
Re: Background Randomizer?
I am sure there is just have to find the script for it.. Not sure where that script goes.
blindbat1457- Forumember
- Posts : 667
Reputation : 6
Language : English
Location : Santa Clarita, CA
Re: Background Randomizer?
See my Forum: Reno Bike Forum
This is advanced stuff but here goes anyway:
Create a php script file like this one on a PHP server you have access to in a folder like D:\WWW\MyWebSite\images\randompic.php:
After you have created the above file on a PHP server, then in the ACP, Display, Pics Management you will add a pointer to the PHP file you created like: http://myphpserver.com/MyWebSite/images/randompic.php
Your forum will run the php code! When you create your images under the image directory, name them like: pic1.jpg, pic2.jpg. You will see in the PHP code that it calls random pictures in this format. If you have trouble doing this get one of your programmer friends to help you clean up the problem. There are many ways that this won't work for you so don't be surprised! Like I said this is advanced stuff...
This is advanced stuff but here goes anyway:
Create a php script file like this one on a PHP server you have access to in a folder like D:\WWW\MyWebSite\images\randompic.php:
- Code:
<?php
function initRand ()
{
static $randCalled = false;
if (!$randCalled)
{
srand((double) microtime() * 1000003);
$randCalled = true;
}
}
function randNum ($low, $high)
{
initRand();
$rNum = rand($low, $high);
return $rNum;
}
$extList = array();
$extList['jpg'] = 'images/jpeg';
$imageNumber = randNum(1, 30);
$img = './pic'.$imageNumber.'.jpg';
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);
}
}
?>
After you have created the above file on a PHP server, then in the ACP, Display, Pics Management you will add a pointer to the PHP file you created like: http://myphpserver.com/MyWebSite/images/randompic.php
Your forum will run the php code! When you create your images under the image directory, name them like: pic1.jpg, pic2.jpg. You will see in the PHP code that it calls random pictures in this format. If you have trouble doing this get one of your programmer friends to help you clean up the problem. There are many ways that this won't work for you so don't be surprised! Like I said this is advanced stuff...
Re: Background Randomizer?
Look at my forum Gangstar15... My forum link is in my post. I have used this same code on other Forumotion forums with little problems. If I am in violation of any of the forum rules then please let me know and I will retract my post.
Re: Background Randomizer?
Your good man! PHP can be used in the pointers to pictures in many different ways, i.e.: Banner, Categories, etc. It can make for some really fun effects changing things up. Use a different category color by day, etc.
I have created shout boxes using php and pointed to our php server using an html page, or even in the message code of the forum. There are all kinds of tweaks you can do in the background if you have access to your own php server and the knowledge to pull it off. Sometimes it can get a little confusing.
My forum is Forumotion through and through. The service they provide rocks!
I have created shout boxes using php and pointed to our php server using an html page, or even in the message code of the forum. There are all kinds of tweaks you can do in the background if you have access to your own php server and the knowledge to pull it off. Sometimes it can get a little confusing.
My forum is Forumotion through and through. The service they provide rocks!
Re: Background Randomizer?
I know php, i mean i know how cool its, i used it for making homepages for online games private server, .
but back to topic ^^
but back to topic ^^
Guest- Guest
Re: Background Randomizer?
Thanks hwystar! I saw the example on your forum and it looks really nice.
I'll try this and get back to you if I have questions.
I'll try this and get back to you if I have questions.
Re: Background Randomizer?
Send me a PM if you need any help! It can get tricky if you don't have any programming experience.
Re: Background Randomizer?
@HWY: So I made the file, it's
sweetcharm.net/randomimage.php
Now..where exactly do I put that URL?
also, where do I put the image urls?.....
sweetcharm.net/randomimage.php
Now..where exactly do I put that URL?
also, where do I put the image urls?.....
Re: Background Randomizer?
Hey HwyStar, this is awesome. You should make a tutorial about this.
By the way, I want to do the same thing to my logo on my forums. Can you show me the code for such (or preferably, PM it?)? That would be amazing.
By the way, when you say add a pointer PHP file in Pics Management, how exactly do I do that? And do I host the images in the same place that I have the PHP file?
I don't know if I should ask this in this topic itself, but thanks CloverTea for asking the question in the first place
By the way, I want to do the same thing to my logo on my forums. Can you show me the code for such (or preferably, PM it?)? That would be amazing.
By the way, when you say add a pointer PHP file in Pics Management, how exactly do I do that? And do I host the images in the same place that I have the PHP file?
I don't know if I should ask this in this topic itself, but thanks CloverTea for asking the question in the first place
Re: Background Randomizer?
The link to your php code goes in the Forum Main Logo field under:
Pictures and Colors, Pics Management, Advanced Mode window of the ACP.
Make sure you specify the http:// as in: http://sweetcharm.net/randomimage.php
The path to your graphic files should reside in the images directory of sweetcharm.net since my php code is referencing that directory. You could modify this line of code to change the images directory to your directory, if you want:
$extList['jpg'] = 'images/jpeg';
Each file I have in the images directory is named: pic1.jpg, pic2.jpg, etc. This way the php code will randomize between 1 and 30. Modify the php code to have the number of files you have created. Modify this line of code to be your number of files:
$imageNumber = randNum(1, 30);
Dragon: I really don't have time to create a tutorial since I run a business and it takes all my time... Once you master this concept Dragon then please pass it forward! Use the code I provided up above in the code segment. CloverTea is close to perfecting the concept as well so she may be able to help you. PM me and I will be happy to help!
Pictures and Colors, Pics Management, Advanced Mode window of the ACP.
Make sure you specify the http:// as in: http://sweetcharm.net/randomimage.php
The path to your graphic files should reside in the images directory of sweetcharm.net since my php code is referencing that directory. You could modify this line of code to change the images directory to your directory, if you want:
$extList['jpg'] = 'images/jpeg';
Each file I have in the images directory is named: pic1.jpg, pic2.jpg, etc. This way the php code will randomize between 1 and 30. Modify the php code to have the number of files you have created. Modify this line of code to be your number of files:
$imageNumber = randNum(1, 30);
Dragon: I really don't have time to create a tutorial since I run a business and it takes all my time... Once you master this concept Dragon then please pass it forward! Use the code I provided up above in the code segment. CloverTea is close to perfecting the concept as well so she may be able to help you. PM me and I will be happy to help!
Re: Background Randomizer?
Oh my gosh I got this to work!!!!!!!!!!!!!!! THANK YOU SO MUCH HWYSTAR FOR ALL YOUR HELP <333 The script looks and works great! I can try to answer questions as people have them as well now.
Similar topics
» Transparent Widget Background (Edit: Or just another background)
» Background image loads before background color
» Background help - aligning for ALL screen sizes OR 2 images to make the background
» Make forum background same as main background? [Solved]
» Help getting background invisible so background image shows thru!
» Background image loads before background color
» Background help - aligning for ALL screen sizes OR 2 images to make the background
» Make forum background same as main background? [Solved]
» Help getting background invisible so background image shows thru!
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum