Welcome to TalkGraphics.com
Results 1 to 10 of 22

Hybrid View

  1. #1
    Join Date
    Jun 2017
    Posts
    4

    Default I need a widget that will display a random photo each time pages is loaded.

    Anybody know how to do this in Xara ? Put a photo in a box on a page. Each time the user lands on the page a different photo is displayed in that spot. Even a reload/refresh page triggers it. On Display. It can be either a random pick or one in a specific sequence. I've found places on the internet that show how to code this, but I don't know php or whether php will work with Xara.

  2. #2
    Join Date
    Aug 2000
    Location
    Placitas, New Mexico, USA
    Posts
    41,507

    Default Re: I need a widget that will display a random photo each time pages is loaded.

    I think this can be done with a script. Check back and see if one of our members can suggest one.

  3. #3

    Default Re: I need a widget that will display a random photo each time pages is loaded.

    Hi,

    you could find a widget, but I would do it as follows:-

    Create a php file called random.php in your root folder (where index.htm is), here is the code for it:-
    <?php
    // RANDOM IMAGE SERVER by Sculptex
    // www.sculptex.co.uk
    // Demo @ random.prevoo.uk

    $path = "random/";
    $files = array_diff(scandir($path), array('..', '.'));
    $imgs = array();
    $i = 0;
    foreach($files as $file) {
    $imgs[]= $file;
    $i++;
    }
    $img = $imgs[rand(0,$i-1)];

    $file_extension = strtolower(substr(strrchr($img,"."),1));
    switch( $file_extension ) {
    case "gif": $ctype="image/gif"; break;
    case "png": $ctype="image/png"; break;
    case "jpeg":
    case "jpg": $ctype="image/jpeg"; break;
    default:
    }
    header("Content-type: " . $ctype);
    header("Expires: ". date("r",time() + (1)));
    readfile($path.$img);
    ?>
    Create a folder called random
    Fill folder with required images
    Create placeholder on your website and insert
    <img src='random.php'>
    You can see it in action at http://random.prevoo.uk
    Last edited by sculptex; 15 July 2017 at 07:39 AM. Reason: fixed url

  4. #4
    Join Date
    Feb 2014
    Location
    Toronto, Canada
    Posts
    792

    Default Re: I need a widget that will display a random photo each time pages is loaded.

    That is neat Sculptex, thank you for sharing.

    Ciao

    Roly

  5. #5
    Join Date
    Jun 2017
    Posts
    4

    Default Re: I need a widget that will display a random photo each time pages is loaded.

    I see on the example web site that every image must be the same size and aspect ratio. Is it possible to vary these in size and aspect ratio?

  6. #6
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,919

    Default Re: I need a widget that will display a random photo each time pages is loaded.

    I followed your instruction to the letter Sculptex but I can only get a missing image icon.
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

 

 

Tags for this Thread

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
  •