if (is_dir($dir)) {
if($handle = opendir($dir)) {
while($file = readdir($handle)) {
// Break the filename by period; if there's more than one piece, grab the last piece.
$parts = explode(".", $file);
if (is_array($parts) && count($parts) > 1) {
$ext = end($parts);
// If it's an image that we want, echo the code.
if ($ext == "png" OR $ext == "PNG" OR $ext == "jpg" OR $ext == "JPG" OR $ext == "jpeg" OR $ext == "JPEG" OR $ext == "gif" OR $ext == "GIF")
echo "<img src=\"$path/$file\" />";
}
}
closedir($handle);
}
...
I'm using it in Wordpress, and the page loads pretty slowly, but it could also be from having a lot of images on it. I just wanted to make sure I wasn't doing something that was frowned upon for performance reasons.