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 { useEffect, useState, useRef } from "react";
|
||||
import { normalizeBackgroundUrl } from "@/lib/avatars";
|
||||
|
||||
interface Preferences {
|
||||
homeBackground: string | null;
|
||||
@@ -49,8 +50,10 @@ export function useBackgroundImage(
|
||||
if (preferences) {
|
||||
const imageKey = `${page}Background` as keyof Preferences;
|
||||
const customImage = preferences[imageKey];
|
||||
const targetImage = customImage || defaultImage;
|
||||
|
||||
const rawImage = customImage || defaultImage;
|
||||
// Normaliser l'URL pour utiliser l'API si nécessaire
|
||||
const targetImage = normalizeBackgroundUrl(rawImage) || defaultImage;
|
||||
|
||||
// Ne changer que si l'image est vraiment différente
|
||||
if (targetImage !== prevImageRef.current) {
|
||||
prevImageRef.current = targetImage;
|
||||
|
||||
Reference in New Issue
Block a user