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

    Function rewriteResponsive

    • Adds srcset (and sizes, when absent) to the <img> tags of html whose src is a same-origin URL that paths matches, and says how many tags changed. A tag that has srcset, data-src or data-srcset, sits inside <picture>, <noscript>, <head> or an HTML comment, names no usable src (empty, a data URL, another origin, a path paths does not match, one that already carries spool-w, or one with a space, comma, quote or fragment in it) is left alone. The original src stays as the fallback. pageUrl resolves a relative src. Everything outside the edited start tags stays byte for byte, and the edits are ASCII.

      Parameters

      Returns { html: string; rewritten: number }