Posted By

shawntorres on 01/29/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrianCoyDesign


Modified "Display pictures in the directory" By kyokutyo


 / Published in: PHP
 

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

  1. <?php
  2. $path = "logoimages/";
  3. $fileTypes = array('jpg','jpeg','gif','png');
  4. $width = 100;
  5. $height = 100;
  6. $pageTitle = "Pictures";
  7.  
  8.  
  9. // *************************************************************
  10.  
  11. $f = join(',*.', $fileTypes);
  12.  
  13. $f = '*.'.$f;
  14.  
  15. $height += 20;
  16.  
  17. ?>
  18.  
  19. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  20. <html xmlns="http://www.w3.org/1999/xhtml">
  21. <head>
  22. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  23. <title>Pictures</title>
  24. <style type="text/css">
  25. <!--
  26.  
  27. .gallery ul { margin-top:10px; list-style:none; }
  28.  
  29. .gallery ul li { width:<?php echo $width; ?>px; height:<?php echo $height; ?>px; float:left; padding:5px; overflow:hidden; margin-bottom:10px; }
  30.  
  31. .gallery ul li span { height:20px; font-size:medium; font-style:italic; }
  32.  
  33. .gallery ul li a img { width:<?php echo $width; ?>px; border:dotted 1px #ddd; }
  34.  
  35. -->
  36. </style>
  37. </head>
  38.  
  39. <body>
  40.  
  41.  
  42. <div id="wrapper">
  43. <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>
  44.  
  45. <div class="gallery" style="display:block; width:100% clear:both;">
  46. <ul>
  47.  
  48. <?php $loop = 1; foreach (glob("$path{".$f."}", GLOB_BRACE) as $fileName) { ?>
  49.  
  50. <li>
  51.  
  52. <a href="<?php echo $fileName; ?>"><img alt="<?php echo $fileName; ?>" src="<?php echo $fileName; ?>" /></a>
  53.  
  54. </li>
  55.  
  56. <?php $loop++; } ?>
  57. </ul>
  58. </div><!-- END GALLERY-->
  59. </div>
  60. <!--END WRAPPER -->
  61.  
  62. </body>
  63. </html>

Report this snippet  

You need to login to post a comment.