how to do a random header with css

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55679

    #1

    how to do a random header with css

    I use this for one of my sites, Thought I would share

    css

    #header {
    height:140px;
    background: #fff url('images/header.php') no-repeat;
    padding:0 0 0 0px;
    text-align: center;
    }

    html

    <div id="header">
    </div>

    php code (rename to header.php)

    http://alistapart.com/d/randomizer/rotate.txt

    enjoy

    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.
  • Jens Van Assterdam
    The Dupre Pimp
    • Feb 2008
    • 6677

    #2
    How to hotlink a image

    <a href="http://galleries.penthouse.com/g/0536/21/?gpid=g950494-pct"><img src="http://www.jensvanassterdam.com/posts/152/karl.jpg" alt="Karlie Montana" target="blank"/> </a>

    Use this at one of my sites..
    thought i would share
    Read TOS for signature rules

    Comment

    • mrkris
      Confirmed User
      • May 2005
      • 2737

      #3
      Why not just have an array of images and use:

      <?php
      srand((float) microtime() * 1000000);
      $images = array('image1', 'image2', 'image3', ....);
      echo $images[array_rand($images)];
      ?>

      Or you could use javascript.

      PHP-MySQL-Rails | ICQ: 342500546

      Comment

      • fris
        Too lazy to set a custom title
        • Aug 2002
        • 55679

        #4
        Originally posted by mrkris
        Why not just have an array of images and use:

        <?php
        srand((float) microtime() * 1000000);
        $images = array('image1', 'image2', 'image3', ....);
        echo $images[array_rand($images)];
        ?>

        Or you could use javascript.
        I was using it in a wordpress theme where it required it to be in css and a div
        Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

        Comment

        • k0nr4d
          Confirmed User
          • Aug 2006
          • 9231

          #5
          Originally posted by Fris
          I use this for one of my sites, Thought I would share

          css

          #header {
          height:140px;
          background: #fff url('images/header.php') no-repeat;
          padding:0 0 0 0px;
          text-align: center;
          }

          html

          <div id="header">
          </div>

          php code (rename to header.php)

          http://alistapart.com/d/randomizer/rotate.txt

          enjoy

          That could will cause high server load because its using GD. I would just do something like

          <?php
          Header("Content-Type: image/jpeg");
          $images = array('img1.jpg','img2.jpg','img3.jpg');
          shuffle($images);
          $string = file_get_contents('headers/'.$images[0]);
          echo $string;
          exit();
          ?>
          Mechanical Bunny Media
          Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

          Comment

          • payd2purv
            Too lazy to set a custom title
            • Jan 2008
            • 2727

            #6
            Originally posted by k0nr4d
            That could will cause high server load because its using GD. I would just do something like

            <?php
            Header("Content-Type: image/jpeg");
            $images = array('img1.jpg','img2.jpg','img3.jpg');
            shuffle($images);
            $string = file_get_contents('headers/'.$images[0]);
            echo $string;
            exit();
            ?>
            sweet. *copy >paste >save*

            Comment

            Working...