We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18940
    • 152 Posts
    With this snippetcall you have a randomimage on pages refreshes with (if you like) a fixed image size (I couldn’t get ’filename’ as alternative text to work)

    I did use copy-paste a lot. Part’s of code by garryn, xyzvisual and Etomite.org laugh

    The call:
    [!nothumbImageRotator!]

    Snippet:
    <?php
    // Change folder, width and height to your own settings.
    // If you don’t want your images change remove --- width=’$width’ height=’$height’ --- at the bottom of this script.
    $folder = ’assets/images/yourgallery’;
    $width=200;
    $height=130;

    $i = 0;
    $imgDir = opendir ($folder);
    while ( $file = readdir( $imgDir ) )
    {
    //checks that file is an image
    $file_type = strrchr( $file, "." );
    $is_image = eregi( "jpg|gif|png",$file_type );

    // The second line below is the leaving files with ’.thumb_’ out. The line below is the original.
    // if ( $file != ’.’ && $file != ’..’ && $is_image )
    if ( !preg_match(’/\.thumb*/’,$file) && $file != ’.’ && $file != ’..’ && $is_image )
    { $images[$i++] = $file; }
    }
    closedir ($imgDir);

    srand( (double) microtime()*1000000 );
    $image_name = $folder . ’/’ . $images[rand( 0,sizeof( $images ) -1 )];

    //ends script if no images found
    if ( $i == 0 )
    die();

    return "<img src=’$image_name’ width=’$width’ height=’$height’ />";
    ?>

    Please post your ideas, suggestions and fixes.
      Quality doesn&#39;t need a big signature.