You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Accepts a “srcset” string and returns an array of objects with the possible properties: url (always), width, height, and density.
string
Type: string
A “srcset” string.
options
Type: object
strict
Type: boolean
Default: false
When enabled, an invalid “srcset” string will cause an error to be thrown. When disabled, a best effort will be made to parse the string, potentially resulting in invalid or nonsensical output.
stringifySrcset(SrcSetDefinitions, options?)
Stringify SrcSetDefinitions. Accepts an array of SrcSetDefinition objects and returns a “srcset” string.
srcsetDescriptors
Type: array
An array of SrcSetDefinition objects. Each object should have a url field and may have width, height or density fields. When the strict option is true, only width or density is accepted.
options
Type: object
strict
Type: boolean
Default: false
Enable or disable validation of the SrcSetDefinition's. When true, invalid input will cause an error to be thrown. When false, a best effort will be made to stringify invalid input, likely resulting in invalid srcset value.
About
Parse and stringify the HTML <img> srcset attribute