Refactor image URL handling: Update API routes to return image URLs via the API instead of direct paths, ensuring consistency across avatar and background uploads. Introduce normalization functions for avatar and background URLs to maintain compatibility with existing URLs.
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 2m57s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 2m57s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { normalizeBackgroundUrl } from "@/lib/avatars";
|
||||
|
||||
export async function getBackgroundImage(
|
||||
page: "home" | "events" | "leaderboard",
|
||||
@@ -16,7 +17,9 @@ export async function getBackgroundImage(
|
||||
const imageKey = `${page}Background` as keyof typeof sitePreferences;
|
||||
const customImage = sitePreferences[imageKey];
|
||||
|
||||
return (customImage as string | null) || defaultImage;
|
||||
const imageUrl = (customImage as string | null) || defaultImage;
|
||||
// Normaliser l'URL pour utiliser l'API si nécessaire
|
||||
return normalizeBackgroundUrl(imageUrl) || defaultImage;
|
||||
} catch (error) {
|
||||
console.error("Error fetching background image:", error);
|
||||
return defaultImage;
|
||||
|
||||
Reference in New Issue
Block a user