Forums

I want a random header image and layer a transparent static image above it (4 posts)

  1. king kork
    Member
    Posted 1 year ago #

    I saw a plugin that will set a random header image from a directory of pictures on the server. That part would be perfect. However, on top of this random image I want to always have a static transparent image. I'm not sure how to make this work with the plugin.

    Does anyone have an idea on how to accomplish that?

    Thanks!

  2. whooami
    Member
    Posted 1 year ago #

    I want to paint my car with this new color, what do you think?

    Do you not need the color in order to answer that question?

    How about providing a download link to the plugin that you are intending to try to use?

  3. drewactual
    Member
    Posted 1 year ago #

    about the plug-in I don't know... I stopped relying on codes of others to do what I wanted.. there is a way you can do this though without using a plug-in. It is stupid easy and incredibly lightweight.....

    track carefully...

    you will need to make a php file. for this purpose I will call it rotate.php. In that file you will need to have this code:

    <?php
    $quotes = ('<strong>http://www.yourdomain.com/rotate.txt</strong>');
    $quotes = file($quotes);
    srand((double)microtime() * 1000000);
    $ranNum = rand(0, count($quotes)-1);
    ?>
    <?php echo ($quotes[$ranNum]); ?>'

    and that is all. notice this however:
    http://www.yourdomain.com/rotate.txt
    you will need to change that to a txt file that resides on your server, and in the same directory as rotate.php . It is a text file which has one URL to a picture per line... an example would be this:

    http://yourdomain.com/yourpic-1.gif
    http://yourdomain.com/yourpic-2.jpg
    http://yourdomain.com/yourpic-3.png

    So now you have
    1. a php file that will randomly generate pictures from a file.
    2. a txt file which provides a URL to the pictures for the php file.

    The txt file must be in same directory as the php file, and the pictures as well. So you will have a parent directory called (speaking purposes) rotate with a file called rotate.php and another called rotate.txt .... then you will have several image files- doesn't matter which format, that you will have randomly generated wherever you want to use them....

    Okay, sweet, but how do I use this?

    like this:

    in your css you will want code that looks something like this:

    #header {
    background: url('url_to_your_rotate.php');
    }

    Now I know that isn't an image, but guess what folks, it works..

    You will now want to put that image in your header right? the static one, as per your original question... how? Just like you would any other time... either hard code it in html or use a php call. What will be rendered is a random image background, and a static picture over top.

    Is that what you wanted?

  4. king kork
    Member
    Posted 1 year ago #

    drewactual - sounds awesome... thanks for the detailed write-up. I'm going to give it a try in a little bit and report back.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic