How do i display a brand new background image on each page refresh online (using Wordpress if the helps anything)? I'd like to consider different screen resolutions, and proper handling with this. Any help could be greatly appreciated.

JavaScript is most likely your best choice for that one.

You will get it in realtime with GD library

To identify screen resolution, you should use client-side javascript


To show another image, you can most likely make use of a script to develop a random number and display the look that ties into it...? You can keep "current" imaage within the session and merely check every time you produce a new random number, that it will not display the final....

This is exactly what I personally use with Wordpress to at random rotate the header images on my small site.

Another person authored the code and that i can't remember who. Place the php code below right into a file named rotate.php, after which put rotate.php in to the directory of images that should be rotated (i.e. "headerimages"), and rotate.php will tap into them. Call rotate.php out of your CSS style sheet in whatever DIV can be used for the headerimage.

I do not know very well what you mean by having the ability to handle different screen resolutions. Consumer screen resolutions?



    Call this way: <img src="">

    Set $folder to the full path to the location of your images.
    For example: $folder = '/user/me/';
    If the rotate.php file will be in the same folder as your
    images then you should leave it set to $folder = '.';


    $folder = '.';

    $extList = array();
    $extList['gif'] = 'image/gif';
    $extList['jpg'] = 'image/jpeg';
    $extList['jpeg'] = 'image/jpeg';
    $extList['png'] = 'image/png';

$img = null;

if (substr($folder,-1) != '/') {
    $folder = $folder.'/';

if (isset($_GET['img'])) {
    $imageInfo = pathinfo($_GET['img']);
    if (
        isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
        file_exists( $folder.$imageInfo['basename'] )
    ) {
        $img = $folder.$imageInfo['basename'];
} else {
    $fileList = array();
    $handle = opendir($folder);
    while ( false !== ( $file = readdir($handle) ) ) {
        $file_info = pathinfo($file);
        if (
            isset( $extList[ strtolower( $file_info['extension'] ) ] )
        ) {
            $fileList[] = $file;

    if (count($fileList) > 0) {
        $imageNumber = time() % count($fileList);
        $img = $folder.$fileList[$imageNumber];

if ($img!=null) {
    $imageInfo = pathinfo($img);
    $contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
    header ($contentType);
} else {
    if ( function_exists('imagecreate') ) {
        header ("Content-type: image/png");
        $im = @imagecreate (100, 100)
            or die ("Cannot initialize new GD image stream");
        $background_color = imagecolorallocate ($im, 255, 255, 255);
        $text_color = imagecolorallocate ($im, 0,0,0);
        imagestring ($im, 2, 5, 5,  "IMAGE ERROR", $text_color);
        imagepng ($im);


Simply have your personal script that at random returns pictures every time it's utilized. I've one which I authored in C in the URL below that returns another pic every time.

Perhaps you have seen this page within the wordpress codex?

It describes how you can rotate the header image. It should not be way too hard adapt it to your requirements.