We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23360
    • 258 Posts
    Giid after-noon all,

    I have a small request.
    I need to dispay an enlarged image which show a topic. Let’s say for the example, the kitchen fourniture.
    I use Lightbox2 and it works fine.

    Now, the problem is the following. When I click on the small image, the enlarged image is displayed wh a black backgroud, but I need to be able the narrow "previous" and "next" to display all images (related to the kitchen fourniture) stored in the folder Kitchen.

    I know that with ligjtbox two, when I add it rel="lightbox[kitchen]" to serveral links of imagesthis rel="lightbox[kitchen]", when I enlarge on of the image, the narrows are showed and I can see all enlarged images of the "familly" of rel="lightbox[kitchen]".

    I am looking for a solution that does the same but for the images stored in a same folder?

    Any idea which will help me?

    Many thank
      • 23360
      • 258 Posts
      Hello all,
      Some has an idea?
      Many thank for your help
        • 4310
        • 2,310 Posts
        A snippet like this will read all the images in a folder and display them as a list like this :
        <ul>
        <li><img src="assets/images/suppliers/prdetail-belvoir-01.jpg" rel="lightbox[suppliers]" /></li>
        <li><img src="assets/images/suppliers/prdetail-pellegrino-02.jpg" rel="lightbox[suppliers]" /></li>
        <li><img src="assets/images/suppliers/prdetail-pellegrino-03.jpg" rel="lightbox[suppliers]" /></li>
        <li><img src="assets/images/suppliers/prdetail-belvoir-02.jpg" rel="lightbox[suppliers]" /></li>
        <li><img src="assets/images/suppliers/prdetail-pellegrino-01.jpg" rel="lightbox[suppliers]" /></li>
        </ul>
        <?php
        $gallery = (isset($gallery)) ? $gallery : 'suppliers';
        $dir_path = (isset($dir_path)) ? $dir_path : 'assets/images/';
        $file_dir = $dir_path.$gallery;
        $output = '';
        $output .= '<ul>'."\r\n";
        if ($handle = opendir($file_dir)) {
            while (false !== ($file = readdir($handle))) {
            if (!eregi("^.thumb", $file)) {
                if($file!="." && $file!=".."){
                    $output .= '<li><img src="'.$file_dir.'/'.$file.'" rel="lightbox['.$gallery.']" /></li>'."\r\n"; 
                }
              }
            }       
        } 
        closedir($handle); 
        $output .= '</ul>'; 
        return $output;
        ?>

        Is that what you meant?
          • 23360
          • 258 Posts
          Hello Bunk.

          It semas to be very interresting, your code but I did not understand well it.

          If I am not wrong, it will showed, on the web page, all images of the folder, within a <li>?
          It is right?

          What I need is similar to this:
          http://www.hello-web.net/option-montagne/index.php?dir=Val_dAPHerens_%28Juillet_2007%29/J2_Prafleuri-Arolla&&desc=J2_Prafleuri-Arolla

          BUT ONLY one of the 55 picture is showed on the web page. Then I click on THAT picture, I can see it enlarged and see the next or previous one, which are all in the same directory

          Is it what does your code?
          But if I understood weel, your code, it will list all images of a folder into one web page, no?

          But in any case, I am very interrested on your code


            • 4310
            • 2,310 Posts
            This should output what you have on the link page, but without the <a title>
            <?php
            $lightbox = (isset($lightbox)) ? $lightbox : 'herenz';
            $large = (isset($large)) ? $large : '/images';
            $thumbs = (isset($thumbs)) ? $thumbs : '/vignettes';
            $gallery = (isset($gallery)) ? $gallery : 'Val_dAPHerens_(Juillet_2007)/J2_Prafleuri-Arolla';
            $dir_path = (isset($dir_path)) ? $dir_path : 'gallery/';
            $file_dir_thumbs = $dir_path.$gallery.$thumbs;
            $file_dir_large = $dir_path.$gallery.$large;
            $output = '';
            if ($handle = opendir($file_dir_thumbs)) {
               $dir_array = array();
                while (false !== ($file = readdir($handle))) {
                if (!eregi("^.thumb", $file)) {
                    if($file!="." && $file!=".."){
                    	$output .= '<a title="" rel="lightbox['.$lightbox.']" href="'.$file_dir_large.'/'.$file.'" target="_blank">'."\r\n";
                        $output .= '<img class="vignette" src="'.$file_dir_thumbs.'/'.$file.' /></a>'."\r\n"; 
                    }
                  }
                }       
            } 
            closedir($handle); 
            return $output;
            ?>
              • 23360
              • 258 Posts
              mmmmh, very interresting smiley
              Thank a lot, I will take care of your suggesstion and keep you informed.
              (I have to work on something else right now...)

              Many thank laugh