Reply to comment

Another Cheap Thumb Gallery Maker

One thing about scripting is that, sometimes, a little fragment of code will get used over and over, and it's not a full-featured app. This script just looks over a directory full of specially named files, and produce a "photo gallery" for it. Hundreds of these scripts have been modified to do all kinds of cool things, but this one doesn't do any of those things. The script just gets copied into a directory, and it produces an index of images. Scripts like this won't ever die. They won't get replaced by more elaborate scripts. They've evolved to fit their niche.

<?php // vi:set ts=4 sw=4 ai:

$files = array();
$dh = opendir('.');
while( $d = readdir($dh) )
{
	if (preg_match('/-400.jpg/', $d))
	{
		array_push( $files, $d );
	}
}
sort($files);
foreach( $files as $d )
{
	$t = preg_replace('/-400/','-800', $d);
	list( $width, $height ) = getimagesize( $d );
	$path = preg_replace('/index\\.php/','',$_SERVER['REQUEST_URI']);
	echo "<a href='$path/$t' target='_blank'><img src='$path/$d' width='$width' height='$height' border='0' /></a><br /><br />";
}
?>

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <dd> <dl> <dt> <i> <li> <ol> <u> <ul> <p> <br> <div> <pre> <code> <img><h1><h2><h3><h4> <blockquote>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

.