Ik heb een hele simpele gallery gevonden en daar nog van alles uitgehaald wat ik niet nodig heb. Zie een klein voorbeeld op: http://www.kleurpunt.nl/gallery/
Wat ik hier nog graag in php zou willen toevoegen is dat zichtbaar wordt welk plaatje van het totaal aantal plaatjes in de directory getoond wordt. Heel subtiel dus:
1/12
of
5/12
Kan iemand mij helpen dit in onderstaand script toe te voegen. Ik heb overal gezocht op internet maar kan niets vinden helaas en zou dus erg geholpen zijn.
Groetjes,
Mirjam
<?php
//---Variables---
$scale = 0;
$maxwidth = 640;
$maxheight = 480;
$thumbmaxw = 50;
$thumbmaxh = 50;
$imgperpage = 10;
$imgperrow = 5;
$pgperrow = 10;
$currentdir = getcwd ();
$typelist = array("jpg","jpeg","gif","png","JPG");
$imagelist = array();
$title = "Pics";
$stylesheet = 'none' ;
$home = "{$_SERVER['PHP_SELF']}";
$this_page = "{$_SERVER['PHP_SELF']}";
$caption = "";
$captionext = "txt";
//--- ind is put to zero when the script is first called uppon---
if(!isset($_GET['ind']))
$_GET['ind'] = 0;
$index = $_GET['ind'];
//---the following code iterates through the directory and puts any image found in the imagelist array---
$dp=opendir($currentdir);
while ( false != ( $file=readdir($dp) ) ) {
if (is_file($file) && $file!="." && $file!=".."){
$extention = explode(".",$file);
$extfield = count($extention)-1;
$extention = $extention[$extfield];
if( in_array($extention,$typelist) ){
array_push ($imagelist,$file);
}
}
}
?>
<!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" xml:lang="en" lang="en">
<head>
<title><?= $title ?></title>
<?
if ($stylesheet == ''){
//--insert the default style sheet into html if none specified
echo '<style type="text/css">'
.'.imag { border-style : solid;'
.'border-color: blue;'
.'border-width : 1px;}'
.'.thumb { border-style : solid;'
.'border-color: #999999;'
.'border-width : 2px;}'
.'A:link { color: #999999;'
.'text-decoration : none; }'
.'A:visited { color: #999999;'
.'text-decoration : none; }'
.'A:hover { color:blue; }'
.'</style>';
} elseif ($stylesheet == 'none') {
//--no style sheet if that is what you want
} else {
echo "<link rel=\"STYLESHEET\" href=\"$stylesheet\" />";
}
?>
<style type="text/css">
<!--
#imageholder {
position:absolute;
top:165px;
width:auto;
height:auto;
z-index:7;
background-color: #FFFFFF;
padding: 20px;
border: 1px solid #CCCCCC;
left: 71px;
}
#caption {
position:absolute;
left:0px;
top:535px;
width:680px;
height:19px;
z-index:8;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666666;
text-align: center;
}
#prevnext {
position:absolute;
left:0px;
top:555px;
width:680px;
height:20px;
z-index:5;
}
#prevnext a:link {
font-weight: normal;
color: #999999;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
text-decoration: none;
}
#prevnext a:visited {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #999999;
font-size: 12px;
text-decoration: none;
}
#prevnext a:hover {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
text-decoration: none;
}
#container {
position:absolute;
left:200px;
top:20px;
width:680px;
height:530px;
z-index:4;
}
.phppgimagebox { margin:0 auto 0 auto;
padding:0;
}
.phppgimageframe { width: auto;
border: 1px solid #CCC;
background-color: #FFFFFF;
padding-top: 20px;
padding-right: 20px;
padding-bottom: 20px;
padding-left: 20px;
}
.phppgimagetag { border: 1px solid #CCC;
}
body {
background-color: #FFFFFF;
}
.phppgnextbox { margin-bottom:5px;
padding:0;
text-align:center;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /></head>
<body>
<div id="container">
<div id="caption">
<div align="center">
<?
if (file_exists ($imagelist[$index]. "." . $captionext) &&
is_file ($imagelist[$index]. "." . $captionext) &&
!is_dir ($imagelist[$index]. "." . $captionext))
include $imagelist[$index]. "." . $captionext;
else
echo $caption; ?>
</div>
</div><div id="prevnext">
<div align="center">
<div class="phppgnextbox">
<? if($index-1 >= 0) {?>
<a href='<?= $this_page ?>?ind=<?= $index-1 ?>'>< prev
<? } ?>
</a>
<? if($index+1 < count($imagelist) ) {?>
<a href="<?= $this_page ?>?ind=<?= $index+1 ?>"> next >
<? } ?>
</a></div>
</div>
</div>
<table align="center" class="phppgimagebox">
<tr>
<td><div class="phppgimageframe">
<?
//--- This is where the large pictures are resized so that they maintain ratio---
$sizeee = getimagesize ("$imagelist[$index]");
$imgwidth = $sizeee[0];
$imgheight = $sizeee[1];
if ($scale == 1 || $imgwidth > $maxwidth || $imgheight > $maxheight) { // decide if img needs to be scaled
$newwidth = $imgwidth/($imgheight/$maxheight);
$newheight = $imgheight/($imgwidth/$maxwidth);
if ($imgwidth < $imgheight) {
if ($newwidth > $maxwidth)
{
?>
<img src="<?= $imagelist[$index] ?>" width="<?= $maxwidth ?>" height="<?= $newheight ?>" alt="" />
<?
} else {
?>
<img src="<?= $imagelist[$index] ?>" width="<?= $newwidth ?>" height="<?= $maxheight ?>" alt="" />
<?
}
} else {
if ($newhight > $maxheight)
{
?>
<img src="<?= $imagelist[$index] ?>" width="<?= $newwidth ?>" height="<?= $maxheight ?>" alt="" />
<?
} else {
?>
<img src="<?= $imagelist[$index] ?>" width="<?= $maxwidth ?>" height="<?= $newheight ?>" alt="" />
<?
}
}
} else { ?>
<img src="<?= $imagelist[$index] ?>" alt="" width="<?= $imgwidth ?>" height="<?= $imgheight ?>" border="0" />
<? }
?>
</div></td>
</tr>
</table>
</div>
<br />
</body>
</html>