viewtopic.php?f=13&t=29211
The code has been updated to now automatically create the gallery based on the images found in the folder the code is being run from. All this works fine but the order is whatever the order is they are found in the folder (alphabetically).
Code: Select all
<div class="property_text-container">
<?php echo 'Gallery for ' . $pid_text; ?>
</div>
<!-- Slideshow container -->
<div class="slideshow-container">
<?php
define('IMAGEPATH_15', dirname(__FILE__).'/'); // '/' is required.
$img_height = 'height: 400px'; // default image height for gallery.
$img_width = 'width: 600px'; // default image width for gallery.
$img_counter_15 = 0;
$img_style_15 = 'style="' . $img_width . '"'; // only needs to be set once here.
$img_total_15 = 0;
// Calculate total number of images before displaying <div>
// If calculated inside foreach() $img_counter always equaks $img_total.
$myVar = count(glob(IMAGEPATH_15."*.{jpg,png,gif,JPG,PNG,GIF}", GLOB_BRACE));
$img_total_15 = $myVar;
/* //Alternate way of calculating number of images:
foreach(glob(IMAGEPATH_15."*.{jpg,png,gif,JPG,PNG,GIF}", GLOB_BRACE) as $var){
$img_total_15 ++; // Calculate total number of images before displaying <div>.
} */
foreach(glob(IMAGEPATH_15."*.{jpg,png,gif,JPG,PNG,GIF}", GLOB_BRACE) as $filename_15){
// $img_total_15 ++; // Needs to be calculated outside foreach().
$img_name_15 = pathinfo($filename_15, PATHINFO_FILENAME);
$img_src_15 = basename($filename_15);
echo '<div class="mySlides fade">';
echo '<div class="numbertext">';
$img_counter_15 ++;
echo $img_counter_15 . ' / ' . $img_total_15;
echo '</div>';
//$img_src = "ext_front.jpg";
// echo '<img src="' . $img_src . '" ' . $img_style . '>';
echo '<img src="' . $img_src_15 . '" ' . $img_style_15 . '>'; // May need backlash before closing chevron.
echo '<div class="text">';
echo $pid_text . '<br>' . img_label($img_name=$img_src_15);
echo '</div>';
echo '</div>';
}
?>
<!-- Next and previous buttons -->
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div><!-- END: div class="slideshow-container"-->
<br>
<!-- Dot container -->
<div class="dot-container">
<!-- The dots/circles -->
<div style="text-align:center">
<?php
$slide_counter = 0;
while ($slide_counter < $img_total_15) {
$slide_counter ++;
echo '<span class="dot" onclick="currentSlide(' . $slide_counter . ')"></span> ';
}
?>
</div>
</div>
I already have the elements in $filename.
Example:
ext_f: displays all front of property
ext_r: displays all rear of property
ext_p: displays pool/spa
rm_l: living room
rm_d: dining room
etc
I looked at uasort() and usort() but not sure if these are the functions I should be looking at.