Return to Snippet

Revision: 23090
at January 29, 2010 16:42 by shawntorres


Initial Code
<?php
$path = "logoimages/";
 $fileTypes = array('jpg','jpeg','gif','png');
      $width = 100;
      $height = 100;
      $pageTitle = "Pictures";

   
      // *************************************************************
  
      $f = join(',*.', $fileTypes);
  
      $f = '*.'.$f;
  
      $height += 20;
  
      ?>
     
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Pictures</title>
<style type="text/css">
      <!--
 
      .gallery ul { margin-top:10px; list-style:none; }

      .gallery ul li { width:<?php echo $width; ?>px; height:<?php echo $height; ?>px; float:left; padding:5px; overflow:hidden; margin-bottom:10px; }
 
      .gallery ul li span { height:20px; font-size:medium; font-style:italic; }

      .gallery ul li a img { width:<?php echo $width; ?>px; border:dotted 1px #ddd; }

      -->
</style>
</head>

<body>


<div id="wrapper">
    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi. Nulla libero. Vivamus pharetra posuere sapien. Nam consectetuer. Sed aliquam, nunc eget euismod ullamcorper, lectus nunc ullamcorper orci, fermentum bibendum enim nibh eget ipsum. Donec porttitor ligula eu dolor. Maecenas vitae nulla consequat libero cursus venenatis. Nam magna enim, accumsan eu, blandit sed, blandit a, eros.</p>
       
       <div class="gallery" style="display:block; width:100% clear:both;">   
          <ul>

<?php $loop = 1; foreach (glob("$path{".$f."}", GLOB_BRACE) as $fileName) { ?>
 
      <li>

      <a href="<?php echo $fileName; ?>"><img alt="<?php echo $fileName; ?>" src="<?php echo $fileName; ?>" /></a>

      </li>

      <?php $loop++; } ?>
      </ul>
      </div><!-- END GALLERY-->
</div>
<!--END WRAPPER -->

</body>
</html>

Initial URL

                                

Initial Description
This worked for me. Original is here: http://snipplr.com/view/5527/display-pictures-in-the-directory/

Initial Title
Modified "Display pictures in the directory" By kyokutyo

Initial Tags

                                

Initial Language
PHP