I used this simple php gallery from a folder on my Joomla 3 site. Now I'm getting ready to do an update to Joomla 4 and I noticed that I have a problem with displaying images from the directory. if I add "echo $dir;" to test it gives me the correct path, although the image is not displayed. When I click "Open image in new tab" on the space where the image should be, the "Joomla Menu alias" is added to the correct path of the image and no image again.
I would note that this code worked fine on Joomla 3. Where is the error? Note: $alias2 is defined before, but I didn't copy that part of the code because it's irrelevant
// (B) GET IMAGES IN GALLERY FOLDER
$current_directory = getcwd();
$dir = $current_directory . '/2000/images/' . $alias2 . '/tmp/';
$images = glob("$dir*.{jpg,jpeg,gif,png,bmp,webp}", GLOB_BRACE);
// (C) OUTPUT IMAGES
$imageCount = count($images);
foreach ($images as $i) {
$img = basename($i);
$caption = substr($img, 0, strrpos($img, "."));
printf("<figure><img src='2000/images/".$alias2."/tmp/%s'><figcaption>%s</figcaption>",
rawurlencode($img), $caption
);
}
?>
</div>
<figure>
element is not closed in your code with</figure>
?