Refactor: Update CDN image delivery URLs

This commit is contained in:
gpt-engineer-app[bot]
2025-10-30 00:58:22 +00:00
parent 4b08836d6d
commit 9f52d423f0
7 changed files with 27 additions and 18 deletions

View File

@@ -12,17 +12,16 @@ export type CloudflareVariant =
| 'logo'
| 'public';
const CLOUDFLARE_ACCOUNT_HASH = import.meta.env.VITE_CLOUDFLARE_ACCOUNT_HASH;
/**
* Build a Cloudflare image URL with specified variant
* Uses CDN proxy for branded URLs
*/
export function getCloudflareImageUrl(
imageId: string | undefined,
variant: CloudflareVariant = 'public'
): string | undefined {
if (!imageId) return undefined;
return `https://imagedelivery.net/${CLOUDFLARE_ACCOUNT_HASH}/${imageId}/${variant}`;
return `https://cdn.thrillwiki.com/images/${imageId}/${variant}`;
}
/**
@@ -53,9 +52,14 @@ export function getBannerUrls(imageId: string | undefined) {
/**
* Extract Cloudflare image ID from various URL formats
* Supports both old imagedelivery.net and new CDN URLs
*/
export function extractCloudflareImageId(url: string): string | null {
// Match imagedelivery.net URLs
const match = url.match(/imagedelivery\.net\/[^\/]+\/([a-f0-9-]+)\//i);
return match ? match[1] : null;
// Match old imagedelivery.net URLs
const deliveryMatch = url.match(/imagedelivery\.net\/[^\/]+\/([a-f0-9-]+)\//i);
if (deliveryMatch) return deliveryMatch[1];
// Match new cdn.thrillwiki.com URLs
const cdnMatch = url.match(/cdn\.thrillwiki\.com\/images\/([a-f0-9-]+)\//i);
return cdnMatch ? cdnMatch[1] : null;
}