Skip to content
@drupflare/spool v1.0.0 GitHub
    Preparing search index...

    Function rewriteEmbeds

    • Replaces each server-rendered YouTube or Vimeo <iframe src> in html with a facade, as options allow, and says how many it replaced and how many it left alone. Only an https, http or protocol-relative src on a known embed host and path, with an id of 6 to 64 letters, digits, - and _, is touched. An iframe inside an HTML comment or <noscript>, one that has srcdoc, and one whose URL sets enablejsapi=1 (the page's script expects the real player) stay as they are; the last is counted as jsapi. An embed that plays on its own by design (see ambient) stays too and is counted as ambient. With page.csp set, and no ignoreCsp, every matching iframe is left alone and counted as csp. The facade keeps width, height, title, class, style, allow, allowfullscreen, loading, id, sandbox and referrerpolicy. Everything outside the replaced start tags stays byte for byte.

      Parameters

      Returns { html: string; rewritten: number; skipped: Record<string, number> }