Add script to list album photos with original filename, add macro for single photo with caption
This commit is contained in:
20
_scripts/list-gallery-photos.php
Normal file
20
_scripts/list-gallery-photos.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
require __DIR__ . '/../_php/autoload.php';
|
||||
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
foreach (glob('gallery/*') as $sAlbumPath) {
|
||||
if (!is_dir($sAlbumPath)) continue;
|
||||
$sAlbum = basename($sAlbumPath);
|
||||
foreach (glob($sAlbumPath . '/*.md') as $sFile) {
|
||||
$sPhoto = basename($sFile);
|
||||
$sContents = file_get_contents($sFile);
|
||||
$aContents = explode("\n", $sContents);
|
||||
$aParts = explode('--', implode("\n", array_slice($aContents, 1)));
|
||||
$aYaml = Yaml::parse(trim(str_replace(" - \n", null, current($aParts))));
|
||||
if (isset($aYaml['file'])) {
|
||||
$sOriginal = basename($aYaml['file'], '.JPG');
|
||||
printf("[%s] %s = %s\n", $sAlbum, $sPhoto, $sOriginal);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user