perf(images): migrate standard img elements to optimized next/image with AVIF/WebP support
Deploy Canina / deploy (push) Successful in 1m47s

This commit is contained in:
parsa committed 2026-08-24 01:20:33 +03:30
1 parent d1e3daf992
commit b91885557e
209 files changed
+254562 -117353

No files matched your search

+17 -1
View File
@@ -43,7 +43,23 @@ export default function SafeImage({
);
}
// Check if external domain is in allowed remote patterns or relative path
const isExternal = typeof src === 'string' && (src.startsWith('http://') || src.startsWith('https://'));
const isBlobOrData = typeof src === 'string' && (src.startsWith('blob:') || src.startsWith('data:'));
const isAllowedHost = React.useMemo(() => {
if (!isExternal) return true;
try {
const url = new URL(src);
const allowedHosts = [
'canina.ir', 'api.canina.ir', 'stage.canina.ir', 'stageapi.canina.ir',
'apicanina.parsaaghayi.ir', 'canina.de', 'www.canina.de',
'images.unsplash.com', 'plus.unsplash.com', 'localhost', '127.0.0.1'
];
return allowedHosts.some(h => url.hostname === h || url.hostname.endsWith(`.${h}`));
} catch {
return false;
}
}, [src, isExternal]);
return (
<div className={cn("relative overflow-hidden group flex items-center justify-center", className)}>
@@ -58,7 +74,7 @@ export default function SafeImage({
width={500}
height={500}
loading="lazy"
unoptimized={isExternal}
unoptimized={isBlobOrData || !isAllowedHost}
className={cn(
"transition-all duration-700 w-full h-full",
imgClassName,