This question is similar to this one.
I'm generating images in a webpage with the following PHP in combination with lazyload.js. The purpose of this PHP is to automatically/dynamically load images from a given directory and to avoid direct hyperlinking. When I try to use various sitemap generators (both online and downloaded), they are only able to see the loader.gif
and not seeing the real images being loaded. I know I can manually create an image sitemap .xml and upload to the Google Search Console, but I'd like to avoid that since I have tons of images, many of which will likely change periodically.
Is PHP like this uncrawlable? Is there another, more elegant solution for generating images dynamically like this, that will play nicely with crawlers? Thanks in advance.
<?php
$dirname = "images/directoryname/";
$images = scandir($dirname);
$ignore = Array(".", "..");
foreach($images as $curimg){
if(!in_array($curimg, $ignore)) {
echo "<img class=\"img-responsive lazy\" src=\"images/loader.gif\" data-original='".$dirname.$curimg."' alt='Alt text goes here' /><br>";
}
}
?>