From 9120c451b9b222c799dfde6e3949810b9fb76d03 Mon Sep 17 00:00:00 2001 From: "Carlos (Almeira)" Date: Fri, 17 Jul 2026 12:21:43 -0500 Subject: [PATCH] Workaround Appwrite 1.9.5 Zero size image string passed bug by using view instead of preview --- src/app/[slug]/page.tsx | 4 ++-- src/app/clasificados/page.tsx | 2 +- src/app/eventos/page.tsx | 2 +- src/app/page.tsx | 2 +- src/components/NewsTicker.tsx | 2 +- src/components/dashboard/MediaGridSelector.tsx | 2 +- src/components/media/StreamOverlays.tsx | 2 +- src/components/publications/PostCard.tsx | 2 +- src/components/publications/RelationSelectField.tsx | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/[slug]/page.tsx b/src/app/[slug]/page.tsx index 89f1344..81c4d4b 100644 --- a/src/app/[slug]/page.tsx +++ b/src/app/[slug]/page.tsx @@ -78,7 +78,7 @@ export async function generateMetadata( const client = await createAdminClient(); const mediaRes = await client.databases.getDocument(APPWRITE_ALMEIRA_CONFIG.databaseId, 'media', post.imagen_destacada_id); if (mediaRes) { - imagenUrl = `${ENDPOINT}/storage/buckets/${mediaRes.bucket_id}/files/${mediaRes.file_id}/preview?project=${PROJECT_ID}&width=1200&height=630&quality=90`; + imagenUrl = `${ENDPOINT}/storage/buckets/${mediaRes.bucket_id}/files/${mediaRes.file_id}/view?project=${PROJECT_ID}&width=1200&height=630&quality=90`; } } catch(e) {} } @@ -129,7 +129,7 @@ export default async function NoticiaDetail({ params }: { params: Promise<{ slug const client = await createAdminClient(); const mediaRes = await client.databases.getDocument(APPWRITE_ALMEIRA_CONFIG.databaseId, 'media', post.imagen_destacada_id); if (mediaRes) { - imagenUrl = `${ENDPOINT}/storage/buckets/${mediaRes.bucket_id}/files/${mediaRes.file_id}/preview?project=${PROJECT_ID}&width=1200&height=600&quality=90`; + imagenUrl = `${ENDPOINT}/storage/buckets/${mediaRes.bucket_id}/files/${mediaRes.file_id}/view?project=${PROJECT_ID}&width=1200&height=600&quality=90`; } } catch(e) {} } diff --git a/src/app/clasificados/page.tsx b/src/app/clasificados/page.tsx index 7a3b064..d524d6a 100644 --- a/src/app/clasificados/page.tsx +++ b/src/app/clasificados/page.tsx @@ -140,7 +140,7 @@ export default async function ClasificadosPage() { const mediaObj = post.resolved_media || (typeof post.imagen_destacada_id === 'object' ? post.imagen_destacada_id : null) as MediaItem | null; if (mediaObj) { - imagenUrl = `${ENDPOINT}/storage/buckets/${mediaObj.bucket_id}/files/${mediaObj.file_id}/preview?project=${PROJECT_ID}&width=800&height=800&quality=85`; + imagenUrl = `${ENDPOINT}/storage/buckets/${mediaObj.bucket_id}/files/${mediaObj.file_id}/view?project=${PROJECT_ID}&width=800&height=800&quality=85`; } return ( diff --git a/src/app/eventos/page.tsx b/src/app/eventos/page.tsx index 8b18c0e..89a8b3d 100644 --- a/src/app/eventos/page.tsx +++ b/src/app/eventos/page.tsx @@ -140,7 +140,7 @@ export default async function EventosPage() { const mediaObj = post.resolved_media || (typeof post.imagen_destacada_id === 'object' ? post.imagen_destacada_id : null) as MediaItem | null; if (mediaObj) { - imagenUrl = `${ENDPOINT}/storage/buckets/${mediaObj.bucket_id}/files/${mediaObj.file_id}/preview?project=${PROJECT_ID}&width=800&height=800&quality=85`; + imagenUrl = `${ENDPOINT}/storage/buckets/${mediaObj.bucket_id}/files/${mediaObj.file_id}/view?project=${PROJECT_ID}&width=800&height=800&quality=85`; } return ( diff --git a/src/app/page.tsx b/src/app/page.tsx index 0eb2635..0a2eb8d 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -220,7 +220,7 @@ export default async function Home(props: { searchParams: Promise<{ [key: string const mediaObj = post.resolved_media || (typeof post.imagen_destacada_id === 'object' ? post.imagen_destacada_id : null) as MediaItem | null; if (mediaObj) { - imagenUrl = `${ENDPOINT}/storage/buckets/${mediaObj.bucket_id}/files/${mediaObj.file_id}/preview?project=${PROJECT_ID}&width=800&height=500&quality=85`; + imagenUrl = `${ENDPOINT}/storage/buckets/${mediaObj.bucket_id}/files/${mediaObj.file_id}/view?project=${PROJECT_ID}&width=800&height=500&quality=85`; } return ( diff --git a/src/components/NewsTicker.tsx b/src/components/NewsTicker.tsx index e2045cd..e2b2a65 100644 --- a/src/components/NewsTicker.tsx +++ b/src/components/NewsTicker.tsx @@ -55,7 +55,7 @@ export default async function NewsTicker() { const media = typeof post.imagen_destacada_id === 'object' ? post.imagen_destacada_id : mediaMap.get(post.imagen_destacada_id); let imagenUrl = post.og_image_url || null; if (media) { - imagenUrl = `${APPWRITE_ALMEIRA_CONFIG.endpoint}/storage/buckets/${media.bucket_id}/files/${media.file_id}/preview?project=${APPWRITE_ALMEIRA_CONFIG.projectId}`; + imagenUrl = `${APPWRITE_ALMEIRA_CONFIG.endpoint}/storage/buckets/${media.bucket_id}/files/${media.file_id}/view?project=${APPWRITE_ALMEIRA_CONFIG.projectId}`; } tickerItems.push({ diff --git a/src/components/dashboard/MediaGridSelector.tsx b/src/components/dashboard/MediaGridSelector.tsx index 69e02b5..da2d39a 100644 --- a/src/components/dashboard/MediaGridSelector.tsx +++ b/src/components/dashboard/MediaGridSelector.tsx @@ -13,7 +13,7 @@ export function getAppwriteImageUrl(fileId: string, bucketId?: string, width = 4 if (isVideo) { return `${endpoint}/storage/buckets/${finalBucketId}/files/${fileId}/view?project=${projectId}`; } - return `${endpoint}/storage/buckets/${finalBucketId}/files/${fileId}/preview?project=${projectId}&width=${width}&height=${height}&quality=80`; + return `${endpoint}/storage/buckets/${finalBucketId}/files/${fileId}/view?project=${projectId}&width=${width}&height=${height}&quality=80`; } interface MediaGridSelectorProps { diff --git a/src/components/media/StreamOverlays.tsx b/src/components/media/StreamOverlays.tsx index 705244b..b6f82c1 100644 --- a/src/components/media/StreamOverlays.tsx +++ b/src/components/media/StreamOverlays.tsx @@ -140,7 +140,7 @@ export const StreamOverlays = () => { if (mediaId) { return ( {activeItem.titulo} diff --git a/src/components/publications/PostCard.tsx b/src/components/publications/PostCard.tsx index 27baaf1..2d42847 100644 --- a/src/components/publications/PostCard.tsx +++ b/src/components/publications/PostCard.tsx @@ -36,7 +36,7 @@ function resolveImageUrl( if (typeof post.imagen_destacada_id === 'object') { const { bucket_id, file_id } = post.imagen_destacada_id; - return `${endpoint}/storage/buckets/${bucket_id}/files/${file_id}/preview?project=${projectId}&width=600&height=400&quality=80`; + return `${endpoint}/storage/buckets/${bucket_id}/files/${file_id}/view?project=${projectId}&width=600&height=400&quality=80`; } // If it's a string, we can't generate a valid URL because it's a document ID, not a file ID. diff --git a/src/components/publications/RelationSelectField.tsx b/src/components/publications/RelationSelectField.tsx index 7765894..7bed253 100644 --- a/src/components/publications/RelationSelectField.tsx +++ b/src/components/publications/RelationSelectField.tsx @@ -186,7 +186,7 @@ function MediaThumbnail({ fileId }: { fileId: string }) { const endpoint = process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT || 'https://appwrite.almeira.com.co/v1'; const projectId = process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID || '69b84df5003bd8957c5c'; - const url = `${endpoint}/storage/buckets/media/files/${fileId}/preview?project=${projectId}&width=400&height=250&quality=80`; + const url = `${endpoint}/storage/buckets/media/files/${fileId}/view?project=${projectId}&width=400&height=250&quality=80`; return (