jquery - How to auto-fill images from a directory in html for Flexslider2? -
i have been searching day , pretty stumped. i've tried searched have had no success.
this problem..
<div id="slider" class="flexslider"> <ul class="slides"> <li><img src="photos/mini-01.jpg"/> <li><img src="photos/mini-02.jpg"/> <li><img src="photos/mini-03.jpg"/> <li><img src="photos/mini-04.jpg"/> </ul> </div> <div id="carousel" class="flexslider"> <ul class="slides"> <li><img src="photos/mini-01.jpg"/> <li><img src="photos/mini-02.jpg"/> <li><img src="photos/mini-03.jpg"/> <li><img src="photos/mini-04.jpg"/> </ul> </div>
what want have auto create lines images based on what's in "photos" folder. using template on many occasions , not want have manually input photos every single time it. talk labour intensive.
any appreciated.
you can php, use function @ top of page.
<?php function images($dir) { $files1 = scandir($dir); foreach ($files1 $x=>$value) { if ($value == "." || $value == ".."){ unset($files1[$x]); } } foreach ($files1 $x=>$value) { echo "<li><img src=\"photos/$value\"></li>"; } } ?>
then when want use it, call image directory name.
<ul> <?php images (your photos directory name here);?> </ul>
Comments
Post a Comment