Results 1 to 2 of 2

Thread: Random Picture Generator

  1. #1
    Join Date
    Jan 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Random Picture Generator

    Ahoy,
    I was trying to think up new ideas for a sig on a forum when I came up with the idea of having separate images that would randomly change when the page gets refreshed. Of course being a typical forum, HTML is not aloud in sigs & the only way to get an image in a sig is using BBcode.

    So I figure the only way to have a different pic, from a pre-selected list of 4, is to make the image file randomly change on load/refresh. Is that possible? How would I go about making that happen?

    Everyone else I've asked says it's impossible, so I wouldn't be to broken hearted if you say the same.

  2. #2
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    hmmmm...

    PHP Code:
    <?php $pics = array(
    array(
    "URL to pic","Mime type"),
    array(
    "otherpic.jpg","image/jpeg"),
    array(
    "directory/differentpic.png","image/png"),
    array(
    "http://domain.com/pic.bmp","image/bmp")
    );
    $key array_rand($pics);
    header('Content-type: '$pics[$key][1]);
    echo 
    file_get_contents($pics[$key][0]); ?>
    put this into a php file on a web server, and replace the URLs with actual URLs(reletive to the php file) and the mime types with the coresponding mime types.
    you can have as many of the inner array()s as you want, as long as you have one comma in between each.

    EDIT: you have to link to that php file in your sig.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •