I need to load some local images.. I used this code before to load some images
<?php
function loopImages(){
$imagePath = get_stylesheet_directory()."/IMAGES/sponsors/";
$filesList =glob($imagePath.'*.{JPG,jpg,PNG,png}', GLOB_BRACE);
echo $filesList;
foreach($filesList as $file){
echo '<img src="'.$file.'">';
}
}
loopImages();
?>
This worked almost fine. I could loop through files and browser could render 8 img tags, but it showed it cannot load local images so I changed get_stylesheet_directory()
to get_stylesheet_directory_uri()
like this
function loopImages(){
$imagePath = get_stylesheet_directory_uri()."/IMAGES/sponsors/";
$filesList =glob($imagePath.'*.{JPG,jpg,PNG,png}', GLOB_BRACE);
echo $filesList;
foreach($filesList as $file){
echo '<img src="'.$file.'">';
}
}
loopImages();
but, it shows nothing. Just nothing. What did I do wrong? How can I render my local images?