mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 13:31:12 -05:00
Refactor: Update CDN image delivery URLs
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user