Changeset 5f3f9ec in Klonkt for src/routes/circle.js


Ignore:
Timestamp:
06/30/2026 11:06:00 PM (2 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
86fa2d2
Parents:
e091add
Message:

fix(cirkel): render a federated video cover as <video>, not a broken <img>

An animated cover that federates as an MP4 (Video attachment) put the video URL into cover_image_url
— circle.js's mediaImage fell back to media[0] even when it was the video — so the Cirkel feed
rendered <img src=...mp4> = a broken image. Now the video is extracted separately (never used as the
cover image) and post-tile/post-card render a muted looping <video> for a video-only cover.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/circle.js

    re091add r5f3f9ec  
    1919  try { return s ? JSON.parse(s) : []; } catch { return []; }
    2020}
    21 function mediaImage(media_json) {
     21// The cover image + (separately) a cover video from a remote note's media. NEVER use a video/audio
     22// item as the cover image — that produced a broken <img> for an animated cover that federated as an
     23// MP4 (the video becomes a <video> instead).
     24function coverMedia(media_json) {
    2225  const media = safeJson(media_json).map((m) => ({ ...m, url: safeUrl(m.url) })).filter((m) => m.url);
    23   return media.find((m) => /image/i.test(m.type || '')) || media[0] || null;
     26  const video = media.find((m) => /video/i.test(m.type || '')) || null;
     27  const image = media.find((m) => /image/i.test(m.type || ''))
     28    || (media[0] && !/(video|audio)/i.test(media[0].type || '') ? media[0] : null);
     29  return { image, video };
    2430}
    2531function htmlToText(html) {
     
    3743    const titleM = (r.content || '').match(/^\s*<p>\s*<strong>([\s\S]*?)<\/strong>/i);
    3844    const realTitle = titleM ? htmlToText(titleM[1]).trim() : '';
    39     const image = mediaImage(r.media_json);
     45    const cover = coverMedia(r.media_json);
    4046    const name = r.author_name || r.author_handle || 'Onbekend';
    4147    return {
     
    4652        : (text ? (text.length > 90 ? text.slice(0, 90) + '…' : text) : name),
    4753      excerpt: '',
    48       cover_image_url: image ? image.url : null,
     54      cover_image_url: cover.image ? cover.image.url : null,
     55      cover_video_url: cover.video ? cover.video.url : null,
    4956      published_at: r.published,
    5057      created_at: r.published,
Note: See TracChangeset for help on using the changeset viewer.