fix: project images not loading - use getCleanImgSrc for grid cards + fix URL path extraction
This commit is contained in:
parent
056f838172
commit
4ed83bbecf
@ -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 ${
|
||||||
|
|||||||
@ -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}`;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user