Page 1 of 1

change background image at every refresh

Posted: Fri May 10, 2019 5:14 pm
by VixxeN
Hello, can someone teach me how to make a script to change background image at every refresh?
I mean, now I will acces the site, then I will refresh / visit a subforum/topic. When I will refresh / visit to get another background image.
For example:
Image
Image

I MUST MENTION: MY STYLE IS WE_UNIVERSAL!

Re: change background image at every refresh

Posted: Fri May 10, 2019 5:43 pm
by stevemaury
Can you provide a link to your phpBB Board?

Re: change background image at every refresh

Posted: Fri May 10, 2019 7:21 pm
by VixxeN
stevemaury wrote:
Fri May 10, 2019 5:43 pm
Can you provide a link to your phpBB Board?
http://sd.rc-rp.ro/

Re: change background image at every refresh

Posted: Fri May 10, 2019 7:34 pm
by VixxeN
stevemaury wrote:
Fri May 10, 2019 5:43 pm
Can you provide a link to your phpBB Board?
I need to mention: I already have the images for random backgrounds.. I mean to upload them to styles folder and randomly applying them.

Re: change background image at every refresh

Posted: Sat May 11, 2019 5:29 am
by Sniper_E
I once created a directory, theme/images/bg.gif/ directory named bg.gif
I put all of my bg images in that directory and found a rotate.php file to put in there.
I renamed the rotate.php to index.php and it randomly selected an image in same directory.
In the colours.css I used "./images/bg.gif" for the background image.

This would work better in an extension. There should be a few out there.

Re: change background image at every refresh

Posted: Sat May 11, 2019 6:20 am
by VixxeN
Sniper_E wrote:
Sat May 11, 2019 5:29 am
I once created a directory, theme/images/bg.gif/ directory named bg.gif
I put all of my bg images in that directory and found a rotate.php file to put in there.
I renamed the rotate.php to index.php and it randomly selected an image in same directory.
In the colours.css I used "./images/bg.gif" for the background image.

This would work better in an extension. There should be a few out there.
Not working at all.. :(

Re: change background image at every refresh

Posted: Sat May 11, 2019 3:05 pm
by Lumpy Burgertushie
the problem is with your style. we universal does not have the same code for the header that most other styles do.

that spot where you want to put the banners is called dashboard or something like that.

none of the extensions or the manual instructions will work as written.

so, you would need random header instructions and use this line in overall_header.html:

Code: Select all

<img src="{ROOT_PATH}styles/we_universal/theme/images/dashboard.jpg?assets_version={T_ASSETS_VERSION}" alt="forum header image">
robert

Re: change background image at every refresh

Posted: Sat May 11, 2019 6:08 pm
by Sniper_E
VixxeN wrote:
Sat May 11, 2019 6:20 am
Not working at all.. :(
I downloaded we_universal again and installed it.
The image path was exactly as Robert stated above.

I went into the theme/images/ directory and created a "New folder"
Then I moved the images, dashboard.jpg and dashboard-FCF.jpg into the New folder directory.
After that I renamed the New folder directory to dashboard.jpg
Then I placed the index.php file in that directory with the images.

It worked great!

This is the random image codes in the index.php

Code: Select all

<?php
/*
By Matt Mullenweg > http://photomatt.net
Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
Latest version always at:
http://photomatt.net/scripts/randomimage
*/

// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = '';

// Space seperated list of extensions, you probably won't have to change this.
$exts = 'jpg jpeg png gif';

$files = array(); $i = -1; // Initialize some variables
if ('' == $folder) $folder = './';

$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
    foreach($exts as $ext) { // for each extension check the extension
        if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
            $files[] = $file; // it's good
            ++$i;
        }
    }
}
closedir($handle); // We're not using it anymore

mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along
header('Location: '.$folder.$files[$rand]); // Voila!
?>

Re: change background image at every refresh

Posted: Sun May 12, 2019 2:21 pm
by ivailo95
omg..i want the same think here..
viewtopic.php?f=496&t=2509346 , but no one look into this topic and now i suspect same topic wow :roll:

now talk in topic: how can i do this , i mean to change background at every refresh

Re: change background image at every refresh

Posted: Sun May 12, 2019 3:23 pm
by KevC
ivailo95 wrote:
Sun May 12, 2019 2:21 pm
omg..i want the same think here..
viewtopic.php?f=496&t=2509346 , but no one look into this topic and now i suspect same topic wow :roll:

now talk in topic: how can i do this , i mean to change background at every refresh
It's worth explaining which background you're talking about.

It turns out this topic is on about the header image.

Some people call the background the image you can see behind the categories on the index, some talk about the image down the side of the index. Unless you say which one you're on about, no one knows. I've said it before, extension requests should explain in as much detail as possible what you want. Some people are extremely vague and then wonder why they get no replies.

Re: change background image at every refresh

Posted: Sun May 12, 2019 4:02 pm
by </Solidjeuh>

Re: change background image at every refresh

Posted: Mon May 13, 2019 7:18 am
by ivailo95
KevC wrote:
Sun May 12, 2019 3:23 pm
ivailo95 wrote:
Sun May 12, 2019 2:21 pm
*long text*
*long text*
i made some edit in my topic

Re: change background image at every refresh

Posted: Sat May 18, 2019 7:26 am
by VixxeN
Sniper_E wrote:
Sat May 11, 2019 6:08 pm
VixxeN wrote:
Sat May 11, 2019 6:20 am
Not working at all.. :(
I downloaded we_universal again and installed it.
The image path was exactly as Robert stated above.

I went into the theme/images/ directory and created a "New folder"
Then I moved the images, dashboard.jpg and dashboard-FCF.jpg into the New folder directory.
After that I renamed the New folder directory to dashboard.jpg
Then I placed the index.php file in that directory with the images.

It worked great!

This is the random image codes in the index.php

Code: Select all

<?php
/*
By Matt Mullenweg > http://photomatt.net
Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
Latest version always at:
http://photomatt.net/scripts/randomimage
*/

// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = '';

// Space seperated list of extensions, you probably won't have to change this.
$exts = 'jpg jpeg png gif';

$files = array(); $i = -1; // Initialize some variables
if ('' == $folder) $folder = './';

$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
    foreach($exts as $ext) { // for each extension check the extension
        if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
            $files[] = $file; // it's good
            ++$i;
        }
    }
}
closedir($handle); // We're not using it anymore

mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along
header('Location: '.$folder.$files[$rand]); // Voila!
?>
Impossible to rename a directory to dashboard.jpg :/

Re: change background image at every refresh

Posted: Sat May 18, 2019 10:25 am
by canonknipser
Why? Do you have a file named dashboard.jpg in the folder where your directory (folder) is placed?

Re: change background image at every refresh

Posted: Sat May 18, 2019 6:30 pm
by Sniper_E
VixxeN wrote:
Sat May 18, 2019 7:26 am
Sniper_E wrote:
Sat May 11, 2019 6:08 pm
Then I moved the images, dashboard.jpg and dashboard-FCF.jpg into the New folder directory.
Impossible to rename a directory to dashboard.jpg :/
If you want to leave the original images in the images/ directory, then name your new folder to sunshine.jpg
Pick a name, just change it in the overall_header.html to match your new directory name.