par
ideal232 » 01 mai 2014, 14:15
bonjour
j'ai un script php qui affiche une galerie d'images en .jpg.
je souhaiterai affiché également des images en .gif , ou.png , ces images sont dans un répertoire nommé:
collection_privee de la façon suivante: 1.jpg 2.gif 3.jpg etc , celui-ci étant dans le répertoire:
tableaux
Voici le code original php:
<div class="container">
<ul class="gallery">
<?php
$captions = array(
/*01*/ "Tableau 1-80x80 cm ",
/*02*/ "Tableau 2-80x80 cm",
/*03*/ "Tableau 3-80x80 cm",
/*04*/ "Tableau 4-80x80 cm",
);
for($n = 1; $n <= count($captions); $n++):
?>
<li>
<a href="#img<?php echo $n; ?>"><img src="tableaux/galerie/<?php echo $n; ?>.jpg" alt="<?php echo $captions[$n-1]; ?> Thumb"></a>
<article id="img<?php echo $n; ?>">
<figure>
<a href="#img<?php if($n == count($captions)) { echo 1; } else { echo $n+1; } ?>"><img src="tableaux/galerie/<?php echo $n; ?>.jpg" alt="<?php echo $captions[$n-1]; ?>"></a>
<figcaption><?php echo $captions[$n-1]; ?></figcaption>
</figure>
<nav>
<a class="close" href="#close">Close</a>
<a class="arrow prev" href="#img<?php if($n == 1) { echo count($captions); } else { echo $n-1; } ?>">Previous</a>
<a class="arrow next" href="#img<?php if($n == count($captions)) { echo 1; } else { echo $n+1; } ?>">Next</a>
</nav>
</article>
</li>
<?php endfor; ?>
</ul>
</div>
le code php accepte que les .jpg .Je ne suis pas encore très doué en php, j'ai essayé cette la modification suivante:
<div class="container">
<ul class="gallery">
<?php
$captions = array(
/*01*/ "Tableau 18-40x80 cm ",
/*02*/ "Tableau 23-100x70 cm",
);
for($n = 1; $n <= count($captions); $n++):
?>
<li>
<a href="#img<?php echo $n; ?>"><img src="tableaux/collection_privee/<?php echo $n; ?>.jpg" alt="<?php echo $captions[$n-1]; ?> Thumb"></a>
<article id="img<?php echo $n; ?>">
<figure>
<a href="#img<?php if($n == count($captions)) { echo 1; } else { echo $n+1; } ?>"><img src="tableaux/collection_privee/<?php
if (file_exists(dirname(__FILE__).'/tableaux/collection_privee/'.$n.'.jpg'))
{
echo $n.'.jpg';
}
else
{
echo $n.'.gif';
}
?>" alt="<?php echo $captions[$n-1]; ?>"></a>
<figcaption><?php echo $captions[$n-1]; ?></figcaption>
</figure>
<nav>
<a class="close" href="#close">Close</a>
<a class="arrow prev" href="#img<?php if($n == 1) { echo count($captions); } else { echo $n-1; } ?>">Previous</a>
<a class="arrow next" href="#img<?php if($n == count($captions)) { echo 1; } else { echo $n+1; } ?>">Next</a>
</nav>
</article>
</li>
<?php endfor; ?>
</ul>
</div>
mais les images .gif ne s'affichent toujours pas. pourriez-vous m'aider. Merci.