Fix anime covers display

This commit is contained in:
DariusIII
2025-12-05 14:37:50 +01:00
parent 90fb01c791
commit efec1e208c
4 changed files with 17 additions and 5 deletions
+1 -1
View File
@@ -507,7 +507,7 @@ if (! function_exists('getReleaseCover')) {
} elseif (! empty($xxxinfo_id)) {
$coverType = 'xxx';
$coverId = $xxxinfo_id;
} elseif (! empty($anidbid)) {
} elseif (! empty($anidbid) && $anidbid > 0) {
$coverType = 'anime';
$coverId = $anidbid;
}
+14
View File
@@ -38,6 +38,20 @@ class CoverController extends Controller
$filePath = storage_path("covers/{$type}/{$filename}");
}
} elseif ($type === 'anime') {
// For anime, check if the ID is valid (must be > 0)
// Reject covers for anidbid <= 0 (failed processing, no match, etc.)
if (preg_match('/^(-?\d+)(?:-cover)?\.jpg$/', $filename, $matches)) {
$anidbid = (int) $matches[1];
if ($anidbid <= 0) {
// Return placeholder for invalid IDs
$placeholderPath = public_path('assets/images/no-cover.png');
if (file_exists($placeholderPath)) {
return response()->file($placeholderPath);
}
abort(404);
}
}
// For anime, try the requested filename first, then fall back to old format (without -cover)
$filePath = storage_path("covers/{$type}/{$filename}");
+1 -2
View File
@@ -125,8 +125,7 @@
</label>
<div class="border border-gray-300 dark:border-gray-600 rounded-lg p-4 bg-gray-50 dark:bg-gray-900">
@php
$coverPath = storage_path('covers/anime/' . $anime['anidbid'] . '-cover.jpg');
$hasCover = file_exists($coverPath);
$hasCover = $anime['anidbid'] > 0 && file_exists(storage_path('covers/anime/' . $anime['anidbid'] . '-cover.jpg'));
@endphp
@if($hasCover)
<img src="{{ url('/covers/anime/' . $anime['anidbid'] . '-cover.jpg') }}"
+1 -2
View File
@@ -61,8 +61,7 @@
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700">
<td class="px-6 py-4 whitespace-nowrap">
@php
$coverPath = storage_path('covers/anime/' . $anime->anidbid . '-cover.jpg');
$hasCover = file_exists($coverPath);
$hasCover = $anime->anidbid > 0 && file_exists(storage_path('covers/anime/' . $anime->anidbid . '-cover.jpg'));
@endphp
@if($hasCover)
<img src="{{ url('/covers/anime/' . $anime->anidbid . '-cover.jpg') }}"