如何在 php 中显示拇指路径照片

how to show thumb path photos in php

如何在 php

中显示缩略图文件夹图像

我有一个名为 albums 的文件夹 在相册中每个文件夹都有照片和缩略图文件夹照片

例子

我的代码只显示这张照片

我只想显示拇指照片

我该怎么做 请帮我解决这个问题 提前致谢

这是代码

<?php

    //path to directory to scan. i have included a wildcard for a subdirectory
    $directory = "albums/*/";

    //get all image files with a .jpg extension.
    $images = glob("" . $directory . "*.jpg");

array_multisort(array_map('filemtime', $images), SORT_DESC, $images);

?>

<?php $num_of_files = 0; $i=0; foreach ($images as $image):?>
<div class="item"><a href="<?php echo basename(pathinfo($image, PATHINFO_DIRNAME)); ?>.html" target="_blank">
<img class="lazyOwl" src="<?php echo $image ?>" />
<p><?php echo basename(pathinfo($image, PATHINFO_DIRNAME)); ?></p>
             </div>
<?php if (++$num_of_files == 3)break; ?>
  <?php if(++$i%3==0): ?>

<?php endif ?>

<?php endforeach ?>

调整目录路径:

$directory = "albums/*/thumb/";

//get all image files with a .jpg extension.
$images = glob($directory . "*.jpg");

...或尝试使用 SPL 工具:

$directory = new RecursiveDirectoryIterator('albums/*/'); // or ('albums/*')
$iterator = new RecursiveIteratorIterator($directory);
$images = new RegexIterator($iterator, '/thumb\/\(.jpe?g|.png)$/i', RecursiveRegexIterator::GET_MATCH);
$images = iterator_to_array($images);
...
// iterating over $images