2) {
$description = implode("
", array_slice($lines, 2));
// A. Match full Instagram URLs (e.g. https://www.instagram.com/studiomajella/) and replace them with a styled link showing just the handle (@studiomajella)
$description = preg_replace(
'/https?:\/\/(?:www\.)?instagram\.com\/([a-zA-Z0-9_\.]+)\/?/i',
'@$1',
$description
);
// B. Match standalone @handles (e.g. @studiomajella) and convert them to Instagram links (avoids matching e-mails)
$description = preg_replace(
'/(?@$1',
$description
);
}
}
// Fallback title from folder name if info.txt is empty
if (empty($title)) {
$cleanName = preg_replace('/^\d+[_|-]/', '', $dir);
$title = str_replace(['_', '-'], ' ', $cleanName);
}
// 2. Find all images/videos in the folder
$mediaList = [];
$allowedImageExtensions = ['jpg', 'jpeg', 'png', 'webp', 'gif'];
$allowedVideoExtensions = ['mp4', 'mov', 'webm'];
if ($handle = opendir($path)) {
while (false !== ($entry = readdir($handle))) {
if ($entry !== '.' && $entry !== '..') {
$ext = strtolower(pathinfo($entry, PATHINFO_EXTENSION));
if (in_array($ext, $allowedImageExtensions)) {
$mediaList[] = [
'src' => 'projects/' . $dir . '/' . $entry,
'type' => 'image',
'filename' => $entry
];
} else if (in_array($ext, $allowedVideoExtensions)) {
$mediaList[] = [
'src' => 'projects/' . $dir . '/' . $entry,
'type' => 'video',
'filename' => $entry
];
}
}
}
closedir($handle);
}
// Sort media items alphabetically by filename
usort($mediaList, function($a, $b) {
return strcmp($a['filename'], $b['filename']);
});
$projects[] = [
'folder' => $dir,
'title' => $title,
'subtitle' => $subtitle,
'description' => $description,
'media' => $mediaList
];
}
}
// Filter out any projects that have no media
$projects = array_values(array_filter($projects, function($proj) {
return count($proj['media']) > 0;
}));
?>
– Bisher keine Projekte geladen –
Erstelle einen Ordner in "/projects/" (z.B. "01_loungesessel"), um Arbeiten anzuzeigen.