method to vary a hosted image?

Discussion in 'HTML & Website Design' started by jazzylee77, Mar 7, 2007.

  1. #1
    I use php on a couple sites to vary an image according to day of the week, day of the year etc.

    I'm wondering if there would be a way to do the same thing when someone hotlinks to an image hosted on my server. The image would be updated then as the date changed.

    Maybe using htaccess?
     
    jazzylee77, Mar 7, 2007 IP
  2. bacanze

    bacanze Peon

    Messages:
    2,419
    Likes Received:
    127
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Great idea, I think it could be done, however im not too sure how to implement it. I dont think htaccess would really be required.
     
    bacanze, Mar 8, 2007 IP
  3. jazzylee77

    jazzylee77 Peon

    Messages:
    578
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm sure it could be done with javascript, but I'd rather have people use a simple image link that displays that days image. I suppose i could change the image file every day...

    I don't htaccess very well. Can an image request be redirected? Could that be dependent on date?
     
    jazzylee77, Mar 8, 2007 IP
  4. jazzylee77

    jazzylee77 Peon

    Messages:
    578
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm finding clues that it can be done...just don't know how to pull it together.
    
    RewriteCond %{TIME_DAY} ^([0-9]{1,2})$
    RewriteCond %{TIME_MONTH} ^([0-9]{1,2})$
    RewriteCond %{TIME_YEAR} ^([0-9]{4})$
    RewriteRule ^/?$1-%2-%3/(.*)$ image.gif?$1
    Code (markup):
    that didn't work
     
    jazzylee77, Mar 8, 2007 IP
  5. jazzylee77

    jazzylee77 Peon

    Messages:
    578
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Got it!

    RewriteRule ^pic.gif$ pic-%{TIME_MON}-%{TIME_DAY}.gif

    then create files named by date like
    pic-03-08.gif
    pic-03-09.gif
    pic-03-10.gif

    at least it works on my site. I don't see why it won't work with hot linking as well.
     
    jazzylee77, Mar 8, 2007 IP
  6. jazzylee77

    jazzylee77 Peon

    Messages:
    578
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Anyone have a clue how I would change this to show yesterday's image and tomorrow's image?
     
    jazzylee77, Apr 7, 2007 IP