fix: resolve 4 media embed bugs from testing

1. Video aspect ratio: remove container border/overflow-hidden, use
   preload="metadata" so browser knows dimensions before play
2. YouTube Error 153: remove sandbox attr (too restrictive), add full
   allow permissions (encrypted-media, accelerometer, gyroscope, etc.)
3. Google Images not displaying: detect image Content-Type from HTTP
   response in metadataFetcher, override classifier to create image
   embed for URLs that serve image/* content
4. Audio seeking broken: add HTTP Range request support in uploads
   route (Accept-Ranges, Content-Range, 206 Partial Content)
This commit is contained in:
Jannis Braun
2026-03-21 00:19:04 +01:00
parent ff2decded5
commit c0133397e3
5 changed files with 58 additions and 11 deletions
@@ -22,6 +22,8 @@ export interface UrlMetadata {
image: string | null;
siteName: string | null;
url: string;
/** Set when the URL itself is a direct media resource (image/video/audio) */
contentType?: string;
}
export async function fetchUrlMetadata(url: string): Promise<UrlMetadata | null> {
@@ -66,6 +68,13 @@ export async function fetchUrlMetadata(url: string): Promise<UrlMetadata | null>
return null;
}
// If the response is a direct media file (image/video/audio), return early
// with the content type — don't try to parse it as HTML
const responseContentType = response.headers.get('content-type') ?? '';
if (responseContentType.startsWith('image/') || responseContentType.startsWith('video/') || responseContentType.startsWith('audio/')) {
return { title: null, description: null, image: null, siteName: null, url, contentType: responseContentType };
}
// Early exit if Content-Length > 512KB
const contentLength = parseInt(response.headers.get('content-length') ?? '0', 10);
if (contentLength > 512_000) {