Browse Source

display og image, not favicon, as fallback

imwald
Silberengel 3 months ago
parent
commit
baa6716fc2
  1. 1
      src/components/WebPreview/index.tsx
  2. 10
      src/services/web.service.ts

1
src/components/WebPreview/index.tsx

@ -475,6 +475,7 @@ export default function WebPreview({ url, className }: { url: string; className?
// Fallback to OG image from website if event doesn't have an image // Fallback to OG image from website if event doesn't have an image
// The OG image is already converted to absolute URL by useFetchWebMetadata // The OG image is already converted to absolute URL by useFetchWebMetadata
// Prioritize: event image tag > OG image from URL metadata (not favicon)
const displayImage = eventImageThumbnail || image const displayImage = eventImageThumbnail || image
// Extract bookstr metadata if applicable // Extract bookstr metadata if applicable

10
src/services/web.service.ts

@ -129,7 +129,15 @@ class WebService {
const basePath = urlObj.pathname.substring(0, urlObj.pathname.lastIndexOf('/') + 1) const basePath = urlObj.pathname.substring(0, urlObj.pathname.lastIndexOf('/') + 1)
image = `${urlObj.protocol}//${urlObj.host}${basePath}${image}` image = `${urlObj.protocol}//${urlObj.host}${basePath}${image}`
} }
logger.info('[WebService] Converted relative image URL to absolute', { originalImage: (doc.querySelector('meta[property="og:image"]') as HTMLMetaElement | null)?.content, absoluteImage: image })
// Filter out favicon URLs - we want OG images, not favicons
const imageLower = image.toLowerCase()
if (imageLower.includes('/favicon') || imageLower.endsWith('/favicon.ico') || imageLower.endsWith('/favicon.svg')) {
logger.warn('[WebService] Filtered out favicon URL from OG image', { url, image })
image = undefined
} else {
logger.info('[WebService] Converted relative image URL to absolute', { originalImage: (doc.querySelector('meta[property="og:image"]') as HTMLMetaElement | null)?.content, absoluteImage: image })
}
} catch (error) { } catch (error) {
logger.warn('[WebService] Failed to convert relative image URL', { image, url, error }) logger.warn('[WebService] Failed to convert relative image URL', { image, url, error })
// Keep original image URL if conversion fails // Keep original image URL if conversion fails

Loading…
Cancel
Save