Pour info j'ai utilisé ce code tiré de phpSources :
<? /* +----------------+ | Configuration | +----------------+ */ $imgpath = ""; // chemins des images $textalter = "image aleatoire"; // texte alternative de l'image (attribut alt) /* +--------------+ | Programme | +--------------+ */ $nodir = 0; if ($imgpath == ".." || $imgpath == "." || $imgpath == "") { $nodir = 1; $imgpath = "."; } $j = strlen($imgpath); $j--; if ($imgpath[$j] != '/' && $imgpath != ".") $imgpath .= '/'; if (is_dir($imgpath)) { if ($condir = opendir($imgpath)) { $i = 0; while (($curfile = readdir($condir)) != false) { $extension = ""; $extension = preg_replace("/.+\.(.{3,4})/", "$1", $curfile); if ($extension == "png" || $extension == "gif" || $extension == "bmp" || $extension == "jpg" || $extension == "jpeg") { $i++; $images{$i} = $curfile; } } if ($images{1} == "") { echo "Aucunes images dans le dossier !"; } else { $i = rand(1, $i); $image = $images{$i}; echo "<img src=\""; if ($nodir != 1) echo $imgpath; echo "".$image."\" alt=\"".$textalter."\" />"; } } else { echo "Impossible d'ouvrir le dossier d'image !"; } } else { echo "Le répertoire d'images spécifié est incorrect !"; } ?>