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

@@ -1,6 +1,7 @@
import { supabase } from '@/integrations/supabase/client';
import { getErrorMessage } from './errorHandler';
import { logger } from './logger';
import { extractCloudflareImageId } from './cloudflareImageUtils';
// Core submission item interface with dependencies
// Type safety for item_data will be added in Phase 5 after fixing components
@@ -735,11 +736,16 @@ async function approvePhotos(data: any, dependencyMap: Map<string, string>, user
// Insert photos into the photos table
const photosToInsert = resolvedData.photos.map((photo: any, index: number) => {
// Extract CloudFlare image ID from URL if not provided
// Supports both old imagedelivery.net and new cdn.thrillwiki.com URLs
let cloudflareImageId = photo.cloudflare_image_id;
if (!cloudflareImageId && photo.url) {
// URL format: https://imagedelivery.net/{account_hash}/{image_id}/{variant}
const urlParts = photo.url.split('/');
cloudflareImageId = urlParts[urlParts.length - 2];
cloudflareImageId = extractCloudflareImageId(photo.url);
// Fallback: parse from URL structure
if (!cloudflareImageId) {
const urlParts = photo.url.split('/');
cloudflareImageId = urlParts[urlParts.length - 2];
}
}
return {