|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
Broken Gallery Thumbnail Images
I've read several threads regarding broken thumbnail problems with notepad's excellent image gallery tutorial, I've tried the suggested solutions and I've obviously not found one that works. Here's exactly what's happening:
http://www.iansamuelharris.com/gallery/images.php If you go to the address above you'll see that the page for the thumbnails is being generated and each thumbnail opens a larger image when clicked, but the thumbs themselves are broken image links. I have the correct path (/home/iansam/iansamuelharris-www/gallery/) in config.php. I have all three php files in /home/iansam/iansamuelharris-www/gallery/ as well. Here's the content of my images.php file: <?php require_once('config.php'); // grab our navigation $nav = isset($_REQUEST['nav']) ? urldecode($_REQUEST['nav']) : null; if(isset($nav)) { $crunch = explode('>', trim($nav)); foreach($crunch as $value) { // IMPORTANT! validate for teh h4x0rz if(!ctype_alnum(str_replace(' ', '', $value))) $invalid = true; } if($invalid) $nav = null; } // decide what page of a paticular gallery we're viewing $pg = isset($_REQUEST['pg']) && (ctype_digit($_REQUEST['pg']) || $_REQUEST['pg'] == 'all') ? $_REQUEST['pg'] : 0; $viewall = is_numeric($pg) ? null : true; $pg = intval($pg) <= 0 ? 1 : $pg; // images per page $section = ROWS * COLS; // last possible ending point for images, depending which page we're on $end = $section * $pg; // starting point for images, depending which page we're on $start = $end - $section; // previous page $prev = $pg - 1; // next page $next = $pg + 1; // start table print('<table border="0" align="center" cellpadding="1" cellspacing="1">'); // draw previous and next links function navigator($total) { $p = '<a href="'.$_SERVER['PHP_SELF'] .'?nav='.rawurlencode($GLOBALS['nav']) .'&pg='.$GLOBALS['prev'].'"><<</a>'; $n = '<a href="'.$_SERVER['PHP_SELF'] .'?nav='.rawurlencode($GLOBALS['nav']) .'&pg='.$GLOBALS['next'].'">>></a>'; $a = '<a href="'.$_SERVER['PHP_SELF'] .'?nav='.rawurlencode($GLOBALS['nav']) .'&pg=all">view all</a>'; // the navigation print('<tr><td align="center" colspan="' . COLS . '">'); if(($GLOBALS['pg'] == 1 && $GLOBALS['end'] >= $total) || isset($GLOBALS['viewall'])) print('<< : view all : >>'); elseif($GLOBALS['pg'] == 1) print('<< : '.$a.' : '.$n); elseif($GLOBALS['end'] < $total) print($p.' : '.$a.' : '.$n); else print($p.' : '.$a.' : >>'); print('</td></tr>'); } // get directory tree function directory($dir) { $mydir = opendir($dir); while(false !== ($file = readdir($mydir))) { if($file != "." && $file != "..") { if(is_dir($dir.$file)) { chdir('.'); $tree[$file] = directory($dir.$file.'/'); chdir('..'); } else { $size = getimagesize($dir.$file); if(in_array($size['mime'], unserialize(TYPE))) $tree[] = $file; } } } closedir($mydir); return $tree; } $tree = directory(PATH); // display category links and images function display_body($navtree) { if(isset($GLOBALS['nav'])) { // we'll need the path as a directory for displaying images for($i=1; $i<count($GLOBALS['crunch']); $i++) $uri .= !is_numeric($GLOBALS['crunch'][$i]) ? $GLOBALS['crunch'][$i].'/' : ''; } if(is_array($navtree)) { if(!is_numeric(implode('', array_keys($navtree)))) { print('<tr><td>'); foreach($navtree as $key=>$value) { if(!is_int($key)) { if(is_array($value)) print('<a href="'.$_SERVER['PHP_SELF'] .'?nav='.rawurlencode($GLOBALS['nav'] .'>'.$key).'">'.$key.'</a><br />'); else print($key.'<br />'); } } print('</td></tr>'); } else { // decide how many rows to display $total = count($navtree); if(isset($GLOBALS['viewall'])) { $check = $total / COLS; $rows = is_int($check) ? $check : floor($check) + 1; } else $rows = ROWS; navigator($total); for($i=0; $i<$rows; $i++) { print('<tr>'); for($n=0; $n<COLS; $n++) { $index = $GLOBALS['start']++; $image = $index < $total ? $navtree[$index] : ' '; print('<td align="center" width="'.THMBWIDTH.'" height="'.THMBHEIGHT.'">'); if($image != ' ') { print('<a href="'.$_SERVER['PHP_SELF'] .'?nav='.rawurlencode($GLOBALS['nav'] .'>'.$index).'">'); print('<img src="imgsrc.php?src=' .PATH.rawurlencode($uri).$image.'" border="0" />'); print('</a>'); } else print($image); print('</td>'); } print('</tr>'); } navigator($total); } } elseif(file_exists(PATH.$uri.$navtree)) { $root = explode('/', dirname(PATH.'.')); print('<tr><td><img src="'.$uri.$navtree.'"></td></tr>'); } else print('<tr><td>invalid request</td></tr>'); } // navigate appropriate categories function categories($navtree) { if(isset($GLOBALS['nav'])) { for($i=1; $i<count($GLOBALS['crunch']); $i++) $navtree = &$navtree[$GLOBALS['crunch'][$i]]; display_body($navtree); } else display_body($navtree); } categories($tree); // end table print('</table>'); ?> And here's my config.php file: <?php // main images directory define('PATH', '/home/iansam/iansamuelharris-www/gallery/'); ?> <?php // valid MIME types, all other files will be ignored define('TYPE', serialize(array('image/jpg', 'image/jpeg', 'image/pjpeg'))); ?> <?php // how many rows of images to display per page define('ROWS', 3); // how many columns of images to display per page define('COLS', 5); ?> <?php // maximum thumbnail width define('THMBWIDTH', 100); // maximum thumbnail height define('THMBHEIGHT', 100); ?> It appears that everything is working fine except for the thumbnail creation. Thanks in advance for any help anyone can offer. |
|
#2
|
|||
|
|||
|
RE: Broken Gallery Thumbnail Images
when i visit your link, i get the msg:
Warning: getimagesize(): Read error! in /home/iansam/iansamuelharris-www/gallery/images.php on line 91 which could hint at a permissions issue. also, viewing the properties of one of your thumbnails gives me this address: http://www.iansamuelharris.com/pages/photos/images/imgsrc.php?src=/home/iansam/iansamuelharris-www/gallery/ian%2F05-11-04001.jpg that confuses me. if you're storing the images and gallery files in: http://www.iansamuelharris.com/gallery/ then why is it using the location: http://www.iansamuelharris.com/pages/photos/images/ ? manually modifying that address to the supposed appropriate location just spits out header errors: http://www.iansamuelharris.com/gallery/imgsrc.php?src=/home/iansam/iansamuelharris-www/gallery/ian%2F05-11-04001.jpg hope that helps. |
|
#3
|
|||
|
|||
|
RE: Broken Gallery Thumbnail Images
PS the updated source for this gallery (that i've been improving here and there) has a web-based admin interface, image descriptions, as well as improved category display/navigation.
if you'd like a copy just gimmie your e-mail. i should probably add it to the code section as well, hmm yes.. |
|
#4
|
|||
|
|||
|
RE: Broken Gallery Thumbnail Images
Looks like something very weird is going on. When I pasted that link into my message I then pasted it into my browser to make sure it was correct and I didn't get that error. Very screwy. Thanks for trying to help, but it appears I've got something going on with my server that I need to get straightened out before I can get this gallery running.
I'd very much like the newer version of your gallery code. My address is sammy(at)candlemann(dot)com. |
|
#5
|
|||
|
|||
|
RE: Broken Gallery Thumbnail Images
some browsers won't display PHP generated warnings, i'm using IE just for your reference. and i'll e-mail that later tonight.
|
![]() |
| Viewing: Codewalkers Forums > Other > Tutorials > Broken Gallery Thumbnail Images |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|