The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

JGF1 (322) [Avatar] Offline
#1
Basically there are a few fixes that should be included.
In images.inc.php
1) is_image_file:
Code differs from book.
Seems there are two versions of thumbs, but one of them causes an array subscript error.
you can't just check for $last - 2 when $last is less than 3.
You end up with 3 images per name:
x.jpg, x.thumb.120.jpg x.thumb.jpg.
So you can just check the first element of bits being not equal to "thumb". (bits array is zero based).

function is_image_file($entry,$path){
$is_image=false;
$bits=explode('.',$entry);
$last=count($bits)-1;
if ($bits[$last]=='jpg'){
//ignore the thumbnails we've already made!
$is_image=$bits[1]!='thumb';
if ($is_image) {
ensure_thumbnail($bits[0],$path);
}
}
return $is_image;
}

2) the position of the '/' is in the wrong place.
You end up with a query string that starts with '/'
You append a directory and get '//dir.pic.jpg/
So you end up with extra '/' on front ` & back end.
Solution
remove '/' and replace with '' (empty string) for first occurrence of $tmp_path in get_breadcrumbs
then on second evaluation of $tmp_path in foreach loop instead of $value.'/', replace with '/'.$value

In index.php, get rid of first closing anchor tag after image. The one after php echo will suffice.