From c85e4b5f8d34320d72c07ef535db3c88e8168e64 Mon Sep 17 00:00:00 2001 From: kuekhaoyang Date: Mon, 24 Nov 2025 18:30:03 +0800 Subject: [PATCH] feat: remove image optimization utility using weserv.nl --- lib/utils/image-utils.ts | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 lib/utils/image-utils.ts diff --git a/lib/utils/image-utils.ts b/lib/utils/image-utils.ts deleted file mode 100644 index e9ef0ff..0000000 --- a/lib/utils/image-utils.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Utility to optimize images using images.weserv.nl - * This service caches images and converts them to WebP, improving load times - * and bypassing some referrer-based blocks. - */ -export function getOptimizedImageUrl(url: string, width?: number, quality: number = 80): string { - if (!url) return ''; - - // Skip optimization for local images or already optimized images - if (url.startsWith('/') || url.includes('weserv.nl')) { - return url; - } - - // Remove protocol for weserv usage - const cleanUrl = url.replace(/^https?:\/\//, ''); - - // Construct weserv URL - // url: source url (without protocol) - // w: width - // q: quality - // output: webp (for better compression) - // l: load (lazy load, though handled by next/image) - // n: no-redirect (returns error image instead of redirecting) - const baseUrl = `https://images.weserv.nl/?url=${encodeURIComponent(cleanUrl)}&output=webp&q=${quality}&n=-1`; - - if (width) { - return `${baseUrl}&w=${width}`; - } - - return baseUrl; -}