The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> New image every 24 hours / or every hour?
dsmith916
post Nov 23 2013, 07:20 AM
Post #1


Advanced Member
****

Group: Members
Posts: 162
Joined: 5-December 12
Member No.: 18,203



Hi. I'd like to have an image on my site that changes to a different image from a directory on my server every day, or once every hour. How do I go about doing this? I haven't found anything promising from any google searches
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 23 2013, 09:35 AM
Post #2


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,606
Joined: 9-August 06
Member No.: 6



It won't happen with HTML, but you could do it with JavaScript.

Get the user's time. If it's past 00 show image X. If it's past 01 show image Y and so forth.

http://www.google.com/search?q=javascript+...image+each+hour
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
dsmith916
post Nov 24 2013, 06:36 AM
Post #3


Advanced Member
****

Group: Members
Posts: 162
Joined: 5-December 12
Member No.: 18,203



QUOTE(pandy @ Nov 23 2013, 09:35 AM) *

It won't happen with HTML, but you could do it with JavaScript.

Get the user's time. If it's past 00 show image X. If it's past 01 show image Y and so forth.

http://www.google.com/search?q=javascript+...image+each+hour


There a lot of different methods and I'm not sure exactly what to do with all of them.

What can I do to get x number of files in folder duncansphotos.com/profileimages/ to change at midnight every night and repeat at the end?

I just want to be able to add photos to this folder and have them show up at the end of the list.

I also need to scale all the images src to width 200
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Nov 24 2013, 09:25 AM
Post #4


.
********

Group: WDG Moderators
Posts: 7,591
Joined: 10-August 06
Member No.: 7



QUOTE(dsmith916 @ Nov 24 2013, 12:36 PM) *

I'd like to have an image on my site that changes to a different image from a directory on my server every day, or once every hour.

How is that question different from http://forums.htmlhelp.com/index.php?s=&am...ost&p=78795 ?

QUOTE
I also need to scale all the images src to width 200

Do you mean the image files or the IMG element?

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Nov 24 2013, 12:18 PM
Post #5


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,606
Joined: 9-August 06
Member No.: 6



QUOTE
I just want to be able to add photos to this folder and have them show up at the end of the list.


In that case you need to do it server side.
http://www.google.com/search?q=php+new+image+each+hour and so forth.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
dsmith916
post Nov 24 2013, 02:36 PM
Post #6


Advanced Member
****

Group: Members
Posts: 162
Joined: 5-December 12
Member No.: 18,203



QUOTE(Christian J @ Nov 24 2013, 09:25 AM) *

QUOTE(dsmith916 @ Nov 24 2013, 12:36 PM) *

I'd like to have an image on my site that changes to a different image from a directory on my server every day, or once every hour.

How is that question different from http://forums.htmlhelp.com/index.php?s=&am...ost&p=78795 ?

It's slightly different. And I had lost that thread.

QUOTE
I also need to scale all the images src to width 200

Do you mean the image files or the IMG element?


1) I want to scale the image elements to width 200 on the page they end up on.

2) I want 1.php to show up one day followed by 2.php the next day and repeat when it reaches the end.

3) I want to be able to add php files to the directory (example 8.php) and have the script automatically include that file in the rotation without modifying the script in any way after I add the file(s)

4) files must change at midnight

This post has been edited by dsmith916: Nov 24 2013, 02:38 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Nov 24 2013, 05:49 PM
Post #7


.
********

Group: WDG Moderators
Posts: 7,591
Joined: 10-August 06
Member No.: 7



QUOTE(dsmith916 @ Nov 24 2013, 08:36 PM) *

1) I want to scale the image elements to width 200 on the page they end up on.

Just give the IMG element a width, but leave out the height (that way the image keeps its proportions). But it's best to do all resizing in the image files themselves.

QUOTE
2) I want 1.php to show up one day followed by 2.php the next day and repeat when it reaches the end.
3) I want to be able to add php files to the directory (example 8.php) and have the script automatically include that file in the rotation without modifying the script in any way after I add the file(s)

Get the day of month with date() --see the PHP manual for details. Get the number of files in a directory with scandir() and count(). Make the script cycle files with the modulus operator (that's the tricky part IMO, see if Brian's code examples in the other thread can help you).

QUOTE
4) files must change at midnight

That's what the floor() function is for.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 25th June 2017 - 05:32 PM