@php
$directory = public_path('assets/img/instalaciones');
$images = [];
if (is_dir($directory)) {
$files = scandir($directory);
$allowedExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp'];
foreach ($files as $file) {
$extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if (in_array($extension, $allowedExtensions)) {
$filePath = $directory . '/' . $file;
$fileDate = filemtime($filePath);
$title = pathinfo($file, PATHINFO_FILENAME);
$title = str_replace(['-', '_'], ' ', $title);
$title = ucwords($title);
$images[] = [
'file' => $file,
'title' => $title,
'date' => $fileDate,
];
}
}
// Ordenar por fecha (más reciente primero)
usort($images, function ($a, $b) {
return $b['date'] - $a['date'];
});
}
@endphp
@forelse($images as $index => $img)
@php
$imgPath = asset('assets/img/instalaciones/' . $img['file']);
$heights = ['320px', '380px', '300px', '360px', '340px', '400px', '310px', '370px'];
$height = $heights[$index % count($heights)];
@endphp
@empty
{{ __('instalaciones.gallery.empty_message') }}
{{ __('instalaciones.gallery.empty_instruction') }}
@endforelse
@if (count($images) > 0)