thumbnail) { return null; } $thumb = $video->thumbnail; $nas = app(NasSyncService::class); // NAS-mirrored path format: "users/{slug}/videos/{song}/…" if (str_starts_with($thumb, 'users/')) { $local = storage_path('app/' . $thumb); if (file_exists($local)) { return $local; } @mkdir(dirname($local), 0755, true); // The DB path mirrors the NAS path exactly — try it directly first. if ($nas->ensureLocalAsset($local, $thumb)) { return $local; } // Extension may differ on NAS (e.g. canonical thumb.webp). $dir = $nas->resolveVideoDir($video); $ext = pathinfo($thumb, PATHINFO_EXTENSION) ?: 'jpg'; foreach (["thumb.webp", "thumb.{$ext}"] as $nasFile) { if ($nas->ensureLocalAsset($local, "{$dir}/{$nasFile}")) { return $local; } } return file_exists($local) ? $local : null; } // Legacy flat filename format. $local = storage_path('app/public/thumbnails/' . $thumb); return file_exists($local) ? $local : null; } }