les vignettes des albums matures sont toujours floutées

This commit is contained in:
Esenjin 2025-01-11 16:59:30 +01:00
parent a8ca9da433
commit 6f9e20283f
3 changed files with 49 additions and 4 deletions

View File

@ -92,7 +92,14 @@ $config = getSiteConfig();
<div class="empty-album"></div> <div class="empty-album"></div>
<?php else: ?> <?php else: ?>
<?php foreach ($album['images'] as $index => $image): ?> <?php foreach ($album['images'] as $index => $image): ?>
<div class="album-image" style="background-image: url('<?php echo htmlspecialchars($image); ?>')"></div> <div class="album-image">
<div class="image-background <?php echo is_array($image) && $image['is_mature'] ? 'mature-preview' : ''; ?>"
style="background-image: url('<?php echo htmlspecialchars(is_array($image) ? $image['url'] : $image); ?>')">
</div>
<?php if (is_array($image) && $image['is_mature']): ?>
<div class="mature-preview-indicator">🔞</div>
<?php endif; ?>
</div>
<?php endforeach; ?> <?php endforeach; ?>
<?php for ($i = count($album['images']); $i < 4; $i++): ?> <?php for ($i = count($album['images']); $i < 4; $i++): ?>
<div class="empty-image"></div> <div class="empty-image"></div>

View File

@ -139,15 +139,22 @@ function getImagesRecursively($albumPath, $limit = 4) {
if ($file->isFile()) { if ($file->isFile()) {
$extension = strtolower($file->getExtension()); $extension = strtolower($file->getExtension());
if (in_array($extension, ALLOWED_EXTENSIONS)) { if (in_array($extension, ALLOWED_EXTENSIONS)) {
// Récupérer les infos du dossier parent de l'image
$parentDir = dirname($file->getPathname());
$parentInfo = getAlbumInfo($parentDir);
$relativePath = str_replace('\\', '/', substr($file->getPathname(), strlen(realpath('./')))); $relativePath = str_replace('\\', '/', substr($file->getPathname(), strlen(realpath('./'))));
$images[] = $baseUrl . '/' . ltrim($relativePath, '/'); $images[] = [
'url' => $baseUrl . '/' . ltrim($relativePath, '/'),
'is_mature' => $parentInfo['mature_content']
];
} }
} }
} }
usort($images, function($a, $b) { usort($images, function($a, $b) {
$pathA = realpath('.') . str_replace(getBaseUrl(), '', $a); $pathA = realpath('.') . str_replace(getBaseUrl(), '', $a['url']);
$pathB = realpath('.') . str_replace(getBaseUrl(), '', $b); $pathB = realpath('.') . str_replace(getBaseUrl(), '', $b['url']);
return filectime($pathB) - filectime($pathA); return filectime($pathB) - filectime($pathA);
}); });

View File

@ -223,6 +223,36 @@ body {
z-index: 2; z-index: 2;
} }
.image-background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.image-background.mature-preview {
filter: blur(10px);
}
.mature-preview-indicator {
position: absolute;
top: 5px;
right: 5px;
width: 24px;
height: 24px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
font-size: 14px;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}
.album-card { .album-card {
background-color: #1e1e1e; background-color: #1e1e1e;
border-radius: 1rem; border-radius: 1rem;
@ -256,6 +286,7 @@ body {
} }
.album-image { .album-image {
position: relative;
width: 100%; width: 100%;
height: 100%; height: 100%;
background-size: cover; background-size: cover;