Function handleMediaFallbacks

  • Attaches an "error" event listener to a media element (img, video, audio) to handle server fallbacks.

    Supports two modes:

    • Blossom URIs: If the element's src is a blossom: URI, parses it and resolves server URLs from xs hints, author hints (via getServers), and builds a fallback chain automatically.
    • HTTP URLs: Extracts the blob hash from the URL, walks the DOM for a data-pubkey attribute, and uses the getServers callback to find alternative servers.

    Parameters

    • element: MediaElement

      The media element (img, video, or audio)

    • getServers: GetServersMethod

      An async method to get an ordered list of servers for a pubkey

    • Optional overridePubkey: string

      An optional pubkey to use instead of walking the DOM

    Returns (() => void)

    A method to remove the "error" event listener

      • (): void
      • Returns void