Skip to content

Instantly share code, notes, and snippets.

@nhaskins
Created August 21, 2011 18:18
Show Gist options
  • Save nhaskins/1160945 to your computer and use it in GitHub Desktop.
Save nhaskins/1160945 to your computer and use it in GitHub Desktop.
old jhaskins.com wp-upload photo gallery
<?php
/*
Template Name: Showcase
*/
?>
<!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="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php wp_get_archives('type=monthly&format=link'); ?>
<?php //comments_popup_script(); // off by default ?>
<?php if (is_single() and ('open' == $post-> comment_status) or ('comment' == $post-> comment_type) ) { ?>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/prototype.js.php"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/effects.js.php"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/ajax_comments.js"></script> <?php } ?>
<?php wp_head(); ?>
</head>
<body>
<!-- warpper start -->
<!-- header end -->
<!-- container start -->
<div align="center" style="margin-top: 50px;">
<?php
$dir_iterator = new RecursiveDirectoryIterator("./wp-content/uploads");
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
$myFiles = array();
// could use CHILD_FIRST if you so wish
foreach ($iterator as $file) {
if (preg_match('/-150x/', basename($file))) {
array_push($myFiles, basename($file)); //pushing the files into the stack as approved... this need to be iterated thru the loop later... shit don't sort yet.
$smallFile = substr(($file), 1); //path to small file, minus the . in front of leading slash
$segments = preg_split('/-150x150/', $file); //pulls apart the 150x150 bit of the file to create the full size img name.
$largeFile = substr($segments[0], 1).'.jpeg'; //puts the segments back togather <filename><.ext>
$url = 'http://'.$_SERVER['HTTP_HOST']; //gives back the base website for use
echo '<a href="'.$url.$largeFile.'" rel="lightbox">';
echo '<img class="showcase" src="'.$url.$smallFile.'"/>';
echo '</a>';
echo "\n";
}
}
//sort($myFiles); //these two lines sort the array generated above... doens't owrk yet
?>
</div>
<!-- content start -->
<!-- content end -->
<!-- container end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment