Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthoralbanwr
    • CommentTimeMay 28th 2007
     
    Hi,
    I'd like to setup random thumbnails from my plogger installation to appear on my homepage. I'm switching our club's gallery from Gallery 2(yuck) to Plogger. We use a joomla installation and I'd like to retain some of the features. One of the main features was having a random thumbnail appear on the homepage that was then directed through to the gallery.

    Has anyone done this with Plogger?
    • CommentAuthorjack
    • CommentTimeJun 7th 2007
     
    http://www.livingos.com/?page_id=31
    • CommentAuthorpandianbe
    • CommentTimeJul 12th 2008
     
    Fine.Great.its working for me.Can we get output as the mode rewrite URL?.


    Thanks !!!
    Pandian
    • CommentAuthorlectric
    • CommentTimeOct 25th 2008
     
    Hi guys, is there a way to modify this so that the images can be placed at different places on the page? For example,

    <a href=random_pic><img src=random_pic></a>

    content content content

    <a href=another_random_pic><img src=another_random_pic></a>
    • CommentAuthorlectric
    • CommentTimeOct 29th 2008
     
    anyone?
    •  
      CommentAuthormemic.a
    • CommentTimeNov 7th 2008
     
    Hi lectric,
    Write this function in plog-functions.php
    Then just call it in the page you want to display a random image using echo get_random_picture();
    its working fine


    function get_random_picture() {

    $connessione_db=mysql_connect("localhost","your_user","your_password");
    mysql_select_db("your_database_name",$connessione_db);

    $tabella = 'plogger_pictures';

    $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM ".$tabella,$connessione_db);

    $offset_row = mysql_fetch_array( $offset_result );

    $offset = $offset_row['offset'];

    $result = mysql_query( " SELECT id,description,caption,path FROM $tabella LIMIT $offset, 1 ",$connessione_db);

    $row = mysql_fetch_array($result);

    $descrizione = $row['description'];

    $path = $row['path'];

    $nome = $row['caption'];

    $id = $row['id'];

    $thumb = generate_thumb($path, $id);

    $pic_url = generate_url("picture",$id);

    $output = '<a class="random-image-link" href="'.$pic_url.'" title="'.$nome.'"><img id="thumb-'.$id.'" class="photos" src="'.$thumb.'" title="'.$nome.'" alt="'.$descrizione.'" width="105" height="105" /></a>';

    $output .= '<div style="text-align:center; padding:0 10px; margin-bottom:10px;"><a href="'.$pic_url.'" title="Visualizza Sfondo: '.$nome.'">'.ucfirst($nome).'</a></div>';

    return $output;

    }


    You can see here the result, (down on the left side of the page) www.memic.net

    Bye
    Thankful People: 1551990
    • CommentAuthor1551990
    • CommentTimeNov 9th 2008
     
    Hi memic.a,
    How can I modify the number of photos showing
    •  
      CommentAuthormemic.a
    • CommentTimeNov 9th 2008
     
    Hi,
    The function I writed display only one random image.
    If you want to display more random pictures you need to call the function more times.

    Like this:

    //this will output 3 random images:

    echo get_random_picture().get_random_picture().get_random_picture();

    // or you can use
    echo get_random_picture();
    echo get_random_picture();
    echo get_random_picture();

    • CommentAuthori-CONICA
    • CommentTimeNov 12th 2008
     
    HI,

    I used the above code, Works great. But I'm not sure exactly where to put the echo.. I put it in index.php but it shows in the head and i can't place it where i'd like. I placed it near the bottom of gallery.php but it remains in the same place.
    What file is it i need to place the echo in to make it show elsewhere?

    Thanks.
    •  
      CommentAuthormemic.a
    • CommentTimeNov 13th 2008
     
    I don't know where you want to put the pics...

    Try putting the code in: collections.php or album.php
    You must insert the code in the theme, not in the index.php or gallery.php.

    Bye
    • CommentAuthorPieperLy
    • CommentTimeNov 14th 2008
     
    hi memic,

    code from above shows random pics and working fine.

    how have you on your site generate the cruft-free url for random pics?

    i have random thumbs on www.mysite.de/index.htm on my site, plogger is in under-directory www.domain.de/plogger-dir/.
    on /plogger-dir/ the cruft-free urls with trailing slash working fine, but on root dir of my site, the links from random thumbs shows www.domain.de/?level=picture&id=1402 instead of www.domain.de/plogger-dir/collection/album/picture/

    have you a solution for this problem?

    thanks for your help and greetings from germany
    uwe
    •  
      CommentAuthormemic.a
    • CommentTimeNov 15th 2008
     
    Hallo PieperLy,

    In the above code the line $pic_url = generate_url("picture",$id);
    should create a cruft-free url for the random pic.
    Maybe it doesn't because you use it outside the gallery folder...
    Try to modify my function and replace the line
    $pic_url = generate_url("picture",$id);

    with


    $pic = get_picture_by_id($id);
    $album = get_album_by_id($pic["parent_album"]);
    $collection = get_collection_by_id($pic["parent_collection"]);
    $pic_url = $config['baseurl'].$collection['path'].'/'.$album['path'].'/'.sanitize_filename(strtolower(get_caption_filename($pic, false)))."/";


    I didn't tried it but should works, I think...
    If it don't work we'll try some other solutions.

    Bye

    p.s (where are you from DE?)
    • CommentAuthorPieperLy
    • CommentTimeNov 15th 2008 edited
     
    hi memic,

    thanks for your help!

    i change your code so:


    /***Funktion für Zufallsbilder auf der Startseite***/

    function get_random_picture() {

    $connessione_db=mysql_connect("localhost","your_user","your_password");
    mysql_select_db("your_database_name",$connessione_db);
    $tabella = 'plogger_pictures';

    $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM ".$tabella,$connessione_db);

    $offset_row = mysql_fetch_array( $offset_result );

    $offset = $offset_row['offset'];

    $result = mysql_query( " SELECT id,description,caption,path FROM $tabella LIMIT $offset, 1 ",$connessione_db);

    $row = mysql_fetch_array($result);

    global $config;

    $descrizione = $row['description'];

    $path = $row['path'];

    $nome = $row['caption'];

    $id = $row['id'];

    $thumb = generate_thumb($path, $id);

    $pic = get_picture_by_id($id);
    $album = get_album_by_id($pic["parent_album"]);
    $collection = get_collection_by_id($pic["parent_collection"]);
    $filename = basename($row["path"]);
    $picture_name = substr($filename, 0, -4);

    $pic_url = $config['baseurl']."bilder/".$collection['path'].'/'.$album['path'].'/'.$picture_name."/";


    $output = '<a class="random-image-link" href="'.$pic_url.'" title="'.$nome.'"> <img id="thumb-'.$id.'" class="photos" src="'.$thumb.'" title="'.$nome.'" alt="'.$descrizione.'" width="158" height="158" /> </a>';

    return $output;
    }


    first added the line:
    global $config;

    then i put my ploggerdir in to the line and change then from caption to name:
    $pic_url = $config['baseurl']."bilder/".$collection['path'].'/'.$album['path'].'/'.$picture_name."/";

    then i added two variables:
    $filename = basename($row["path"]); / this is the picture name
    $picture_name = substr($filename, 0, -4); / delete the *.jpg file-extension from url

    now it works on my index, see it here on left down: >> Bilder

    ...
    thanks also to all ploggerianer - plogger is a nice and great gallery script and it make fun.
    ciao
    PieperLy
    ps: ahso, memic,...i live in berlin...and thanks again for your help
    •  
      CommentAuthormemic.a
    • CommentTimeNov 15th 2008
     
    I'm happy that works.
    If you need some other help just ask.
    ciao ciao
    • CommentAuthorPieperLy
    • CommentTimeNov 22nd 2008
     
    a little supplement with a drop of bitterness:
    when you use random thumbs on site and use html tags on description, you must remove the "quotation marks"
    from it - otherwise show html code beside random thumbs.
    • CommentAuthorffd8
    • CommentTimeNov 5th 2009
     
    quick update to this great code listed here - I didn't want to have to enter in my database login/pass again, so this takes advantages of the common config file and can be easily dropped into the bottom of 'plog-functions.php' [version 1.0 -RC1]:

    function get_random_picture() {


    $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM `".PLOGGER_TABLE_PREFIX."pictures`");

    $offset_row = mysql_fetch_array( $offset_result );

    $offset = $offset_row['offset'];

    $result = mysql_query( " SELECT id,description,caption,path FROM `".PLOGGER_TABLE_PREFIX."pictures` LIMIT $offset, 1 ");

    $row = mysql_fetch_array($result);

    global $config;

    $descrizione = $row['description'];

    $path = $row['path'];

    $nome = $row['caption'];

    $id = $row['id'];

    $thumb = generate_thumb($path, $id);

    $pic = get_picture_by_id($id);
    $album = get_album_by_id($pic["parent_album"]);
    $collection = get_collection_by_id($pic["parent_collection"]);
    $filename = basename($row["path"]);
    $picture_name = substr($filename, 0, -4);

    $pic_url = $config['baseurl'].$collection['path'].'/'.$album['path'].'/'.$picture_name."/";
    $fullsize = $config['baseurl']. 'plog-content/images/'.$collection['path'].'/'.$album['path'].'/'.$picture_name.".jpg";

    $output = '<a class="random-image-link" href="'.$pic_url.'" title="'.$nome.'"> <img id="thumb-'.$id.'" class="photos" src="'.$thumb.'" title="'.$nome.'" alt="'.$descrizione.'" /> </a>';

    return $output;
    }


    If anyone's interested in having the image be a full size rather than thumbnail, simply replace the output img src- with $fullsize rather than $thumb.

    cheers and thanks again to all the previous posters/coders!
    •  
      CommentAuthorkimparsell
    • CommentTimeNov 7th 2009
     
    @ffd8: There is no need to modify the plog-functions.php file. There is already a plugin that does this built into version 1.0-RC1.

    Log into your gallery admin section, hit the Plugins tab, and click the "Use this plugin" link for the Random Images plugin. A white box will appear with the proper code for the php include that you can add to your template.