以前作成したWeb写真アルバム「神戸散歩 2017.5 ~ 2019.3」「大阪散歩 2017.6 ~ 2019.3」の続編「神戸散歩(2) 2019.4 ~ 2022.3」「大阪散歩(2) 2019.4 ~ 2022.3」を作成。
PHPプログラム「thumbnail-create.php」で、自動生成している。 例として、ディレクトリ「kobe2」の下に2つの解像度のJPEG画像を入れておき、
kobe2 > 320 kobe2 > 800
以下のようにディレクトリ「kobe2」を指定してPHPプログラムを開くと、HTMLが自動生成される。
http://localhost/2nd/album/thumbnail-create.php?dir=kobe2
【thumbnail-create.php の PHPプログラム部分抜粋】
<div id="gallery"> <?php $cwd = getcwd(); $dir = $_GET['dir']; $open_path = $cwd.'/'.$dir.'/320'; if ($opendir = @opendir($open_path)) { // @ : エラー制御演算子 (E_WARNINGを出さないため) $files = scandir($open_path); natcasesort($files); $order = 0; foreach ($files as $file) { if (!is_dir($open_path.'/'.$file)) { ?> <a href="photo.html?photo=<?= $dir ?>/800/<?= $file ?>"> <div class="box-frame"><div class="vignette"><img src="<?= $dir ?>/320/<?= $file ?>"></div></div> </a> <?php } } closedir($opendir); } ?> </div>