Page 1 of 1

New picture every day?

Posted: Sun Jan 01, 2023 11:02 am
by alan_sh
Is there a way to show a new picture on a web page every day? Obviously, I would preload the pictures, but I haven't seen anything which lets me show just one picture.

cheers - and Happy New Year

Alan

Re: New picture every day?

Posted: Sun Jan 01, 2023 1:54 pm
by BaconFries

Re: New picture every day?

Posted: Sun Jan 01, 2023 4:54 pm
by alan_sh
Thanks - I understand the code, but I am unsure how to incorporate it into my site.

Any thoughts?

Re: New picture every day?

Posted: Sun Jan 01, 2023 6:06 pm
by KingSparta
Page, page html

Re: New picture every day?

Posted: Sun Jan 01, 2023 6:50 pm
by alan_sh
KingSparta wrote: Sun Jan 01, 2023 6:06 pm Page, page html
Thanks - I'll give it a go

Re: New picture every day?

Posted: Sun Jan 01, 2023 6:52 pm
by BaconFries
KingSparta wrote: Sun Jan 01, 2023 6:06 pm Page, page html
@kingsparta Yes but where? as there is a correct way to ibsert :?
Alan using the script from Dani Web you can insert the javascript as follows Page HTML between <head></head> tags* the image <div></div> insert where you wish to be displayed in what you are using (Layout Grid, Flex) Note you will need to rename the image names to match your own. You may also just want to try using inserting a image as you would normally within the software for the first image. ⁹

Between the <head></head>

Code: Select all

<script>
var dailyPhotos;
var today, img;

dailyPhotos = function() {

   today = new Date();
   weekday = today.getDay();
   showImages = [ ];
   myPhotos = [ "sundayPhoto.jpg", "mondayPhoto.jpg", "tuesdayPhoto.jpg", "wednesdayPhoto.jpg", "thursdayPhoto.jpg", "fridayPhoto.jpg", "saturdayPhoto.jpg" ]; // You must specify the path or file name of your images that will be loaded in a weekday basis.

    if ( document.images ) {
       for ( var x = 0; x < myPhotos.length; x++ ) { 
       showImages[ x ] = new Image();
       showImages[ x ].src = myPhotos[ x ];          
     } img = (( document.getElementById ) ? document.getElementById("yourImageId") : document.images.yourImageId ); // Specify the id of the image that will get raplaced daily.
        img.src = showImages[ weekday ].src;
        img.alt = myPhotos[ weekday ];         
   } return false; // If the browser can't display images, then EXIT FUNCTION.
};
   window.onload = dailyPhotos;

</script>

Code: Select all

Insert where you need
<div id="main">
<img id="yourImageId" src="tuesdayPhoto.jpg" alt="DEMO" />
</div>

Re: New picture every day?

Posted: Sun Jan 01, 2023 10:53 pm
by alan_sh
Thanks - I'll try that in the morning

Re: New picture every day?

Posted: Sun Jan 01, 2023 11:58 pm
by KingSparta
it works, you just need to point it to your image folder, right now it is looking in the root folder on the server.