fix: project images not loading - use getCleanImgSrc for grid cards + fix URL path extraction

This commit is contained in:
parsa aghaei 2026-06-29 14:00:22 +03:30
parent 056f838172
commit 4ed83bbecf
2 changed files with 4 additions and 3 deletions

View File

@ -203,7 +203,7 @@ export default function Projects({ dict }: MyProjectsProps) {
{project.images.map((image, idx) => ( {project.images.map((image, idx) => (
<Image <Image
key={idx} key={idx}
src={process.env.NEXT_PUBLIC_BACK_URL + "/images/projects/" + image.src} src={getCleanImgSrc(image.src)}
alt={`Image for ${project.title}`} alt={`Image for ${project.title}`}
fill fill
className={`object-cover transition-transform duration-500 group-hover:scale-110 ${ className={`object-cover transition-transform duration-500 group-hover:scale-110 ${

View File

@ -5,7 +5,8 @@ export const getCleanImgSrc = (src: string): string => {
if (!src) return '/images/placeholder.jpg'; if (!src) return '/images/placeholder.jpg';
if (src.startsWith('http://') || src.startsWith('https://')) { if (src.startsWith('http://') || src.startsWith('https://')) {
const urlPath = new URL(src).pathname; const urlPath = new URL(src).pathname;
return urlPath.startsWith('/storage') ? urlPath : `/images${urlPath}`; return urlPath;
} }
return src; if (src.startsWith('/')) return src;
return `/images/projects/${src}`;
}; };