Hi,
I would really appreciate some help with my php problem. I'm pretty new to php and have been trying to understand more by adapting a php script a friend wrote for me that looks in a folder and displays the jpgs it finds as a set of thumbnails linked to larger images.
See here: http://www.squirl-art.com/illustrati...rationmain.php
I wanted to take this script and combine it with the jquery galleria ( http://code.google.com/p/galleria/) to make a prettier gallery.
All my attempts so far have failed, the page works but it doesn't find the images.
I need the php to output an unordered list that Galleria can work from.
The folder structure is
Main folder - php script
- images (main image folder) - images (images folder)
- thumbs (thumbs folder)
I don't actually need the thumbs folder anymore as the Galleria script generates it's own. I only left it in as I thought it would be easier to figure out that way.
I've only included the php and a section of the html where the php function is called.
Can anyone help me?
PHP Code:
<?php
$directory = 'images'; $thumbfolder = 'thumbs'; $imagefolder = 'images';
function get_images($dir, $imgs, $thmbs) {
$thumbs = $dir.'/'.$thmbs; $images = $dir.'/'.$imgs; if ($handle = opendir($thumbs)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..'){
echo '<li><img rel="'.$images.'/'.$file.'" class="thumb" style="width: 75; height: 75px; margin-left: 0px; opacity: 0.3;" src="'.$thumbs.'/'.$file.'" alt="'.substr($file, 0, -4).'" title="'.substr($file, 0, -4)."></li>"; } } } else { echo '<p>Directory not available</p>'; }}?>
the function is called in the html like this
HTML Code:
<div class="demo">
<ul class="gallery_demo_unstyled gallery_demo galleria">
<h1>David Small</h1>
<?php
get_images($directory, $imagefolder, $thumbfolder);
?>
</ul>
<p class="nav"><a href="#" onclick="$.galleria.prev(); return false;">« previous</a> | <a href="#" onclick="$.galleria.next(); return false;">next »</a></p>
</div>
Last edited by barebones; 05-07-2009 at 04:14 AM..
|