Random Photo Plug-In

Any chance anybody could whip up a random photo style plug-in (and by plug-in I mean line of php code). Better yet would be the option to choose "random photo" or "random photo from specific album".

And it might not make sense to simply pull a random photo. Instead it might be more useful to display the thumbnail for a random photo and then link directly to that photo within it's own album.

Thank you very much.
«1

Comments

  • luv Member
    Hello,

    I'm looking for ways on how to display random image per album. Is there a way to achieve this? There's no option for this in the program. There are about 200 photos in one album and viewers dont really go through all images on the albums so it's the same pictures are getting viewed. At least randow view based on file names.

    Thank you.
  • fatman Member
    I have made a php file for display random images for external site(I show some random image on wordpress blog sidebar), if anybody interested, I could post the code here.
  • acrylian Administrator, Developer
    Of course, right on, we will add it then to your wordpress extensions page then.
  • acrylian Administrator, Developer
    Thanks.
  • luv Member
    really nice! thanks.
  • acrylian Administrator, Developer
  • luv Member
    The extension made by fatman is different from [url]http://www.zenphoto.org/documentation-official/zenphoto/_template-functions.php.html#functiongetRandomImages[/url] right? How to set getRandomImages? Is this the line where I should set?

    [code]$imageWhere = " AND " . prefix('images') . ".`show`=1"[/code]

    Thanks.
  • luv Member
    fatman,

    Thank you for this piece of code. I have few questions because I cant seem to make it work.

    1.) I placed random.php under zp-core and tested on the browser using http://mylocalgallery.com/zenphoto/zp-core/random.php?
    num=9&height=50&width=50. I also tried with "class=" but it's not working.

    There are boxes of thumbnails but the pictures are not showing. It displayed the filename of the image. I got this "Zenphoto Error: the requested object was not found." error when I clicked on the thumbnail.

    2. If I set the parameters or default value for num, height, width, class on random.php, will "http://mylocalgallery.com/zenphoto/zp-core/random.php" work?
  • acrylian Administrator, Developer
    luv, fatman's extension is meant to be used on a external site/pages that are not administrated by zenphoto (like a wordpress blog for example) while the function randomimages() is for zenphoto pages only.
  • luv Member
    Hi acrylian,

    So how to set getRandomImages? I only have one album with 200 images.

    Thank you.
  • acrylian Administrator, Developer
    Please follow the links to our documentation I posted above. And maybe read this before: http://www.zenphoto.org/2008/04/how-to-read-the-zenphoto-functions-guide/
  • I would like to have fatman's random image display on external site but php is not my strength. Here is the code for a gif image (images/slikom.gif) which serves as the link to my zenphoto gallery. When you click the gif it opens page with gallery. I would like to have instead of that gif image random image by fatman that does the same job, takes you to the gallery.

    This is code i have now to do the above described job:
    `

    image


    `
    Where should I put fatman's code for the external php site?
    `@readfile('http://yourgallery.com/zen/zp-core/random.php?

    num=15&height=120&width=120&class=one-image&album=damjanci-ponaosob')`
    I already have random.php in place. Does random.php has to be edited in any way?
  • fatman Member
    you may try

    `





    <?php @readfile('http://yourgallery.com/zen/zp-core/random.php?<br />
    num=15&height=120&width=120&class=one-image&album=damjanci-ponaosob') ?>





    `
  • @fatman
    It's working!!! Thank you very much. I would like to have it on click to open main zenphoto site instead of random photo you clicked on. That way visitors would be aware of all albums there. I guess this could be done with changing values in random.php but again I'm not sure which one should be changed. Could you please point me to that value?
  • I had succeed according fatman's method. please go mysite http://girlsspot.info and see the effection on the right bar. You may set up a table or frame.
  • Very nice web site and of course girls. The fatman's code works for me too but I was just asking what should I change to have the random image (on the external site) being linked to the main zenphoto site instead of to the full size random photo in the target album.
  • acrylian Administrator, Developer
    You have to change the url in the random.php file. Look at this line: `$randomImageURL = getURL($randomImage);`
    Replacing `getURL($randomImage);` with `getGalleryIndexURL()` should work.
  • I did replace it as you advised but I got the following error:

    Parse error: syntax error, unexpected T_ECHO in /home/da_mja_nac/public_html/da_mja_nci/zen/zp-core/random.php on line 36
  • acrylian Administrator, Developer
    Sorry, I just did a quick look/guess and please note I actually never tried this script...
  • hi, this script doesn't work anylonger, can you help me please ?
    http://www.zenphoto.org/trac/ticket/555
    i updated from zenphoto version 1.2.4 [3841] to 1.2.5 [4110]
  • thats the message i got
    "Zenphoto Error
    Bad gallery in album instantiation"
  • acrylian Administrator, Developer
    In case you trying to get the image from a dynamic album, please see: http://www.zenphoto.org/trac/ticket/1161
  • i copied the random.php from http://www.zenphoto.org/2008/01/hacks/#random-image-external-site to my zp-core - i didn't create a dynamic album - where should i find that .alb file if one exists ?

    i'm also using this script

    <?

    define('ZENFOLDER', 'zp-core');
    define('WEBPATH', 'zenphoto');
    require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");

    $randomImage = getRandomImages();

    echo "<img src='". $randomImage->getSizedImage(getOption('image_size')) . "'
    alt=\"random image\"\n" . $randomImage->getTitle() . '" />';

    ?>
  • acrylian Administrator, Developer
    .alb files are dynamic albums and therefor within the albums folders like normal albums.

    Sorry, I can't help with that random addon as I did not write it. Try to contact its developer or maybe he will still visit this forum.
  • do have an other random script for me to use external ?
  • The `bad album instantiation` problem is fixed now. Just as a note, this error message is part of the development builds. It is intended to help us find places where the zenphoto code is not correctly passing a gallery object. If you get the error, it would help us if you change the DEBUG_ERROR define to `true` as it will give details on where the bad instantiation occurred.
  • i changed now to debug_error true and got this message

    Zenphoto Error
    Bad gallery in album instantiation

    Backtrace:

    in Album->Album (template-functions.php [3356])
    in getRandomImages (zp-foto-random-script.php [18])

    line 18 in zp-foto-random-script.php is
    $randomImage = getRandomImages();
  • Ok, you are using zenphoto functions outside of the zenphoto gallery, aren't you? The varialbe $_zp_gallery is not set. You may run into any number of these. I suggest you include the following code in your script:
    `$_zp_gallery = new Gallery();`
    before you call any functions.

    We will try to make a general solution to this as well.
Sign In or Register to comment.