Function rewriteResponsive
-
rewriteResponsive(
html: string,
options: ResponsiveOptions,
context: { pageUrl: string; paths: RegExp },
): { html: string; rewritten: number }Parameters
- html: string
- options: ResponsiveOptions
- context: { pageUrl: string; paths: RegExp }
Returns { html: string; rewritten: number }
Adds
srcset(andsizes, when absent) to the<img>tags ofhtmlwhosesrcis a same-origin URL thatpathsmatches, and says how many tags changed. A tag that hassrcset,data-srcordata-srcset, sits inside<picture>,<noscript>,<head>or an HTML comment, names no usablesrc(empty, a data URL, another origin, a pathpathsdoes not match, one that already carriesspool-w, or one with a space, comma, quote or fragment in it) is left alone. The originalsrcstays as the fallback.pageUrlresolves a relativesrc. Everything outside the edited start tags stays byte for byte, and the edits are ASCII.