Refreshing background for simple.php [Closed]

Hi bitsostring, do you know how one would be able to set that background image to refresh every X seconds, please?

Hadn’t thought about that #-o

The actual image file is refreshed every minute because it’s the one I use for my PWS dashboard webcam, but of course the Simple background doesn’t refresh unless you refresh the page. . .

Yeah, the image I am using auto updates every minute, at present I am using action tiles and that has an auto refresh, problem there is is flashes white when it refreshes, bit annoying, I will have a search on the met tomorrow see if I can come up with sommat

I found these on the WWW but neither work or I’ve got the URL wrong or sommat, any thoughts?

   header("Refresh: 1; URL=$simple.php");

Seems like overkill to refresh the whole page?

Theres 2 different versions there as seen here but i cant get either to work, if it worked I’d have been happy with it. Just seemed far simpler to look for a way to auto refresh the page than to do just the image itself.

Figured it out, i had it placed in the section around line #84 where all the header stuff is, so i added the little bit of code (below) on line #15 set to 60 seconds, works great, I’m using the forecasticonnew.jpg this giving me the actual current conditions for the background as seen [i][b][color=orange]here[/color][/b][/i].


In which script, simple.php?

In simple.php

Yes, it works there, but as my image is defined in _data.php

$body_image  = '../out1.jpg';   # comment this line if no background image required 
if (isset ($body_image) && $body_image <> '' && file_exists($body_image) )
     {  $weather['body_image']     = $body_image; } 

I thought I’d try it there. . .

Works fine, with (I think) less disruption :slight_smile:

Yeah, that’s where my image is defined but it didn’t refresh the image automatically, you still have to refresh the page to see the change, i also don’t see a timer there either?

Thats why i added the wee snippet to simple.php, its most definitely the wrong way to do it but its the only way i could find that was simple enough to do, of course, having it change using ajax is also easy enough to do but the way i would do it would be to hack code form elsewhere, that would also mean more lines of code cause i don’t know what I’m doing :slight_smile: its working and i do not notice it change either, not on the tablet, if i watch it on the laptop browser, all i can see is the favicon refresh, nothing else is noticeable unless the image has changed of course…

My webcam image file out1.jpg is updated every minute and my Simple $reloadTime = 20, so “Refresh:65” allows time for any data change flashtime and ensures a new $weather[‘body_image’].

How often is your forecasticonnew.jpg updated?

I agree it’s a crude way to do it, but it works :slight_smile:

So there is another refresh/reload for the background image?

My data refreshes every 2 seconds, I didn’t know there was another reload? My forecasticonnew.jpg updates every minute but I can only set it to upload every 5 minutes, I need to find an app that will upload for me, all my options in wd are used up lol.

I am looking to do this myself now that I have set a jpg refreshing webcam up
I’ve got to be honest, this thread has got me a bit confused.
If someone can confirm the “best way to do this” from what has been shared I’d be grateful!

@bitofstring helped be put my current background image on my simple view dash so is it just a case of replacing that URL and adding some kind of refresh? Or does the 30 secs data refresh take care of that anyway?


My simple site:
My main site:

It was this

However Im still not sure about getting the image to refresh every 30 secs like that data

I just added header(“Refresh:60”); on about line 15 of simple.php
That refreshes the page every 60 seconds, does the job for me

I can try to explain what I did. . .

  1. My webcam image out1.jpg is uploaded every 60 secs, and overwrites the previous image.

  2. I defined the image to use in _data.php, as described before:

$body_image  = '../out1.jpg';   # comment this line if no background image required 
  1. I added a new line 26 to _data.php (immediately after the routine to save loaded scripts):

The 65 secs allows for any data change flashtime and makes sure you do get a new image.

The normal AJAX data refresh won’t do it.

Whether it is the “best way” or not I don’t know :slight_smile:


I’ve got the image itself working ok, but not the refresh

Do you mean go from this:

# -------------------save list of loaded scrips;
if (!isset ($stck_lst) ) {$stck_lst = '';}
$stck_lst      .= basename(__FILE__).' ('.__LINE__.') version =>'.$scrpt_vrsn_dt.PHP_EOL;       
$from_dir       = getcwd().'/'; # echo 'from_dir = '.$from_dir . PHP_EOL;

To this:

# -------------------save list of loaded scrips;
if (!isset ($stck_lst) ) {$stck_lst = '';}
$stck_lst      .= basename(__FILE__).' ('.__LINE__.') version =>'.$scrpt_vrsn_dt.PHP_EOL;       
$from_dir       = getcwd().'/'; # echo 'from_dir = '.$from_dir . PHP_EOL;

Yes, but put a semicolon at the end of the new line.

Awesome thanks for helping
Now changed so will keep an eye on it