Displaying all images within a folder

by skyvia
2 replies
  • WEB DESIGN
  • |
I believe I have a simple question...

On my website will be various folders and within each folder will be anywhere from 1-10 images and/or pdf files. Is there a simple way with html or a template of some sort so that when the user goes to that folder, all the files within the folder are displayed in some organized fashion?

Thanks
#displaying #folder #images
  • Profile picture of the author ram07
    hi,

    if you use php, then this will help you to list the images within the folder.....

    <?php
    // the directory, where your images are stored
    $imgdir = '/images/';

    // list of filetypes you
    $allowed_types = array('png','jpg','jpeg','gif');

    $dimg = opendir($imgdir);
    while($imgfile = readdir($dimg))
    {
    if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
    {
    $a_img[] = $imgfile;
    sort($a_img);
    reset ($a_img);
    }
    }

    // total image number
    $totimg = count($a_img);

    for($x=0; $x < $totimg; $x++)
    {
    $size = getimagesize($imgdir.'/'.$a_img[$x]);

    // do whatever
    $halfwidth = ceil($size[0]/2);
    $halfheight = ceil($size[1]/2);
    echo '<li><img src="%27.$imgdir.%27%27.$a_img%5B$x%5D.%27"></li>';
    }

    ?>

    Thank you.....
    {{ DiscussionBoard.errors[3526842].message }}
  • Profile picture of the author ptpasta
    Or if you work with WP, you could use NEXTgen Gallery plugin.
    {{ DiscussionBoard.errors[3531083].message }}

Trending Topics