I have been working around a gallery for hours and I can not get it to work, I am a PHP beginner and I would appreciate any help. Attachment code below.
In the gallery there are thumbnails and when you click the big picture takes you. The problem is that the big images do not open. The gallery is on the page of each product, where each one has an ID and a folder of its own, that is, the product 200 has the folder 200 where there are the large photos together with a subfolder 'thumbs'.
Product folder - > large images.
Thumbs folder - > small images.
To show the 2 folders from PHP, I understand that logically you have to open 2 directories with opendir (product folder and thumbs folder), therefore you have to do 2 whiles through the images of each directory, but I'm not sure if the code is fine, they are put in a row, is that correct?
As I said the thumbnails in the thumbs folder, they are loaded, but those in the directory of the large photos, no. This is the code of the gallery - On the other hand, if I put an image on the route.jpg as such instead of the variable $ file2 then the large image is loaded.
I have checked the routes are fine, I sense that it must be a logic failure or question of keys ... I hope to have explained. Thanks in advance.
Product code.php (inside a div):
<?php
$ruta = "img/content/producto/$_GET[id]/thumbs/"; // Indica ruta para thumbnails
$filehandle = opendir($ruta); // Abrir archivos
while ($file = readdir($filehandle)) {
if ($file != "." && $file != "..") {
$tamanyo = getimagesize($ruta . $file);
$ruta2 = "img/content/producto/$_GET[id]/"; // Indica ruta para imagen grande
$filehandle2 = opendir($ruta2); // Abrir archivos
while ($file2 = readdir($filehandle2)) {
if ($file2 != "." && $file2 != "..") {
$tamanyo2 = getimagesize($ruta2 . $file2);
}
}
?>
To show the gallery:
<a data-fancybox="gallery" href="img/content/producto/<?php echo $_GET['id']?>/imagen.jpg">
<img src="<?php echo $ruta.$file ?>" width="200px" height="auto" style="float:left;"></a>
To close
<?php
}
}
closedir($filehandle); // Fin lectura archivos
closedir($filehandle2); // Fin lectura archivos