Skip to content

Instantly share code, notes, and snippets.

@chasereeves
Created April 11, 2012 18:24
Show Gist options
  • Save chasereeves/2361153 to your computer and use it in GitHub Desktop.
Save chasereeves/2361153 to your computer and use it in GitHub Desktop.
PHP: List all images from directory
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>&lt;img src="Matterful"&gt;</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Chase Reeves">
<!-- Date: 2012-04-04 -->
<style type="text/css" media="screen">
*{margin:0;padding:0;}
body{font-family:'helvetica Neue',helvetica,arial,sans-serif;font-weight:200;color:#222;background-color:#f1f1f1;}
.group::after{content:".";display:block;height:0;clear:both;visibility:hidden;}
img{width:100%;}
a{text-shadow:0 1px 0 #FFF;overflow:hidden;}
a,a:visited{color:#222;text-decoration:none;}
a:hover{color:#666;}
nav{display:block;margin:0 0;background-color:#999;padding:6px;}
nav a{font-variant:small-caps;}
#text a{display:block;float:left;width:220px;margin:10px;text-shadow:0 1px 0 #FFF;overflow:hidden;}
#text{padding:20px;border-bottom:1px solid #FFF;}
#images{border-top:1px solid #ddd;padding:20px;}
#images li{width:14.6%;margin:100px 1%;float:left;height:200px;overflow:hidden;list-style:none;}
.webkit #images li{width:14.7%;margin:1%;}
#images a{margin:0 0 10px 0;}
</style>
</head>
<body>
<nav><strong>i.matterful.co</strong> &nbsp; | &nbsp; <a href="/index-txt.php">no img</a></nav>
<?php
$images = glob("{*.gif,*.jpg,*.png}", GLOB_BRACE);
echo "<ul id=\"images\" class=\"group\">";
foreach($images as $image) {
echo "<li><a href=\"$image\"/>$image</a>\n<img src=\"$image\"/></li>\n";
}
echo "</ul>";
?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
<!--
(function($){
$(function(){
var $body = $('body');
if($.browser.webkit) {
$body.addClass('webkit')
}
});
}(jQuery));
-->
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment