Automatic detection of missing thumbnails and shows nothumb.png

This commit is contained in:
alopexc0de 2013-02-19 01:42:25 -05:00
parent ea8c4d84f0
commit cccdd39978

View File

@ -42,16 +42,25 @@
function noimg(){ // Shown in place of the image if one isn't available function noimg(){ // Shown in place of the image if one isn't available
$thelist = ''; $thelist = '';
// Last Modified not working, so removed for the time being $thethumbs = '';
$_SESSION['thethumbs'] = '';
if($handle = opendir('Pictures')){ if($handle = opendir('Pictures')){
while(false != ($file = readdir($handle))){ while(false != ($file = readdir($handle))){
if($file != "." && $file != ".." && $file != ".htaccess"){ if($file != "." && $file != ".." && $file != ".htaccess"){
//$thelist .= '<a href="?img='.$file.'"><img src="thumbs/'.$file.'" alt="Thumbnail for '.$file.'" /><br /> └ '.$file.'</a></font><br /><p></p>'."\n";
$thelist .= "-".$file; $thelist .= "-".$file;
} }
} }
closedir($handle); closedir($handle);
} }
if($thumbs = opendir('thumbs')){
while(false != ($fiel = readdir($thumbs))){
// Test if thumbnail exists if not show nothumb.png
if($fiel != "." && $fiel != ".." && $fiel != ".htaccess"){
$thethumbs .= "-".$fiel;
}
}
closedir($thumbs);
}
echo " echo "
<p> <p>
Please specify an image with the url: Please specify an image with the url:
@ -63,11 +72,16 @@
<h4>Uploaded Pictures:</h4> <h4>Uploaded Pictures:</h4>
"; ";
$thelist = explode("-", $thelist); $thelist = explode("-", $thelist);
$thethumbs = explode("-", $thethumbs);
foreach($thelist as $pics){ foreach($thelist as $pics){
if($pics == '' || $pics == null){ if($pics == '' || $pics == null){
echo ''; echo '';
}else{ }else{ // Checks if there is a thumbnail for the image, if not show nothumb.png
if(in_array($pics, $thethumbs)){
echo '<a href="?img='.$pics.'"><img src="thumbs/'.$pics.'" alt="'.$pics.'" title="'.$pics.'"/></a>'."\n "; echo '<a href="?img='.$pics.'"><img src="thumbs/'.$pics.'" alt="'.$pics.'" title="'.$pics.'"/></a>'."\n ";
}else{
echo '<a href="?img='.$pics.'"><img src="nothumb.png" alt="'.$pics.'" title="'.$pics.'"/></a>'."\n ";
}
} }
} }
echo" echo"