Bonjour,
Voila, je me suis mis récement au php et donc je débute. J'héberge un petit site qui a notament pour vocation de rassembler l'histoire de notre troupe de scouts.
Depuis un moment je m'éforce de faire une galerie de photos avec miniatures générées automatiquement, je suis presque au bout de mes peines, mais j'ai un soucis, je m'explique :
- Dans ma page apercu_photo j'affiche la première photo du répertoire (le répertoire en variable dans l'url) et avec les boutons suivant/précédent les gens peuvent naviguer et en dessous j'affiche les miniatures de toutes les photos du répertoire qui sont générées si elles n'éxistent pas avec un mélange de php et de javascript.
Jusque là pas de problème.
Mais j'aimerais pourvoir mettre un
lien sur chaque miniature qui affiche la photo correspondante au dessus .
J'ai déjà essayé différentes solutions qui n'ont malheuresement jamais fonctionnées...
Voici un lien pour l'exemple :
http://92.188.68.203:4000/index.php?page=apercu_photo&titre=2008&chemin=Apercu_Photos/2008/SUF%20-%20Sortie%20 éclaireur%20-%2029_09_2007%20-%20Photos%20sortie%20et%20mât
Un généreux codeur pourrait-il m'aider à faire ceci ? et éventuellement corriger mon code qui est probablement mal foutu.
Merci d'avance.
Et voici mon code :
------------------------------------------------------------------------------------------------------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Language" content="fr">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Apercu des Photos</title>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0" link="#000080" vlink="#000000" alink="#FF0000">
<tt><center>
<table border="1" width="860" id="table5" style="border-width: 0px" cellspacing="0" cellpadding="2">
<tr>
<td style="border-style: none; border-width: medium" height="21">
</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium">
<div style="border-bottom-style: solid; border-bottom-width: 1px; padding-bottom: 1px">
<p style="margin-top: 0; margin-bottom: 0">
<font face="Verdana" size="2" color="#CC3300">
<?php
$titre_page = $_GET['titre'];
echo 'Extrait des photos de '.$titre_page;
$nb_photo = 0;
?>
</tt></font></p>
</div>
</td>
<tr>
<td style="border-style: none; border-width: medium" height="20">
</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" height="20">
<p align="center">
<p>
<DIV ID=ejs_photo_box></div>
<script type="text/javascript">
ejs_photo = new Array;
<?php
$chemin_photo = $_GET['chemin'];
$a = 0;
$handle = opendir("$chemin_photo");
while (($file = readdir())!=false)
{
clearstatcache();
if($file!=".." && $file!=".")
{
echo "ejs_photo[$a] = '$chemin_photo/$file'; ";
$a++;
}
$nb_photo = $nb_photo + 1;
}
closedir($handle);
?>
</script>
</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium">
<script type="text/javascript">
function ejs_aff_photos(num)
{
if(document.getElementById)
{
ejs_fin = "";
if(num!=0)
{
ejs_fin += "<table border='0' width='100%'><tr><td align='left' width='4'><A HREF=# onClick='ejs_aff_photos("+(num-1)+");return(false)'><img src='images/suivant_gauche.gif' border='0'></A></td><td align='left'><A HREF=# onClick='ejs_aff_photos("+(num-1)+");return(false)'><font face='Verdana' size='2' color='#CC3300'>Photo précédente</font></td></A>";
}
else
{
ejs_fin += "<table border='0' width='100%'><tr>";
}
if(num!=(ejs_photo.length-1))
{
ejs_fin += "<td align='right'><A HREF=# onClick='ejs_aff_photos("+(num+1)+");return(false)'><font face='Verdana' size='2' color='#CC3300'>Photo suivante</font></A></td><td align='right' width='4'><A HREF=# onClick='ejs_aff_photos("+(num+1)+");return(false)'><img src='images/suivant_droite.gif' border='0'></A></td></tr></table>";
}
document.getElementById("ejs_photo_box").innerHTML = "<CENTER><IMG SRC='"+ejs_photo[num]+"' BORDER=0><BR>"+ejs_fin+"</CENTER>";
}
}
window.onload = new Function("ejs_aff_photos(0)")
</script>
</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" height="21" width="800">
<center>
<?php
$chemin_photo_a = $_GET['chemin'];
$handle_a = opendir("$chemin_photo_a");
$chemin_photo_mini = $chemin_photo_a_mini;
$handle_b = opendir("$chemin_photo_mini");
$numero_photo = 0;
while (($file_a = readdir())!=false)
{
clearstatcache();
if($file_a!=".." && $file_a!=".")
{
$fichierSource_a = "$chemin_photo_a/$file_a";
$miniature_a = "mini_$file_a";
$chemin_mini_a = "$chemin_photo_a"._mini;
$chemin_mini_photo_a = "$chemin_mini_a/$miniature_a";
// echo $chemin_mini_photo_a;
// Génère les miniatures si elles n'éxistent pas
if((file_exists($chemin_mini_photo_a))!=true)
{
$source_a = ImageCreateFromJpeg($fichierSource_a);
$largeurSource_a = imagesx($source_a);
$hauteurSource_a = imagesy($source_a);
$largeurDestination_a = $largeurSource_a /6;
$hauteurDestination_a = $hauteurSource_a /6;
$im_a = ImageCreateTrueColor ($largeurDestination_a, $hauteurDestination_a)
or die ("Erreur lors de la création de l'image");
$blanc = ImageColorAllocate ($im_a, 255, 255, 255);
$gris[0] = ImageColorAllocate ($im_a, 255, 255, 255);
$gris[1] = ImageColorAllocate ($im_a, 255, 255, 255);
$gris[2] = ImageColorAllocate ($im_a, 255, 255, 255);
$gris[3] = ImageColorAllocate ($im_a, 255, 255, 255);
for ($i=0; $i<=3; $i++)
{
ImageFilledRectangle ($im_a, $i, $i, $largeurDestination_a-$i, $hauteurDestination_a-$i, $gris[$i]);
}
ImageCopyResampled($im_a, $source_a, 8, 8, 0, 0, $largeurDestination_a-(2*8), $hauteurDestination_a-(2*8), $largeurSource_a, $hauteurSource_a);
ImageJpeg ($im_a, $chemin_photo_a.'_mini/'.$miniature_a);
}
$numero_photo_a = $numero_photo_a + 1;
echo '<a href="
http://92.188.68.203:4000/index.php?page=apercu_photo&titre=%27 $titre_page.'&chemin='.$chemin_photo_a.'">';
echo '<img src="
http://92.188.68.203:4000/index.php?page=apercu_photo&titre=%27 $chemin_photo_a.'_mini/'.$miniature_a.'" border="0" />';
echo '</a>'
}
}
closedir($handle_a);
?>
</center>
</td>
</tr>
<tr>
<td style="border-style: none; border-width: medium" height="21" width="800" align="right">
<?php
$nb_photo = $nb_photo -2;
echo '<font face="Verdana" size="1">'.$nb_photo.' photos disponibles</font>';
?>
</td>
</tr>
</table>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------------------------
Afficher la suite