Reference / @open-music-sdk/util-artwork / artworkSrcSet
Function: artworkSrcSet()
function artworkSrcSet(
artwork,
width,
options?
): string;Defined in: artwork.ts:338
A srcset for an image shown width CSS pixels wide: one candidate per pixel density, so a dense screen gets a sharper image and a plain one a smaller file.
Each candidate carries the density it was asked for. Where the artwork does not come large enough for one, the largest it has is offered once, under the density that image amounts to.
As with artworkUrl, where the URLs point is not checked unless hosts says where they may.
Parameters
artwork
The artwork as the API gave it: the URL template and, where it says, how large the image comes.
width
number
How wide the image is shown, in CSS pixels.
options?
The densities to offer, and what artworkUrl takes.
Returns
string
The srcset value: one url Nx candidate per density, joined by commas; or the one URL alone, with no density, where the template has no size to fill in.
Throws
TypeError if artwork is not an object with a url, options is not an object, width, height or a density is not a number above 0 and at most 2^53 - 1 (so Infinity is refused), densities is not a list of 1 to 16, format or crop is not one the image server takes, hosts is not a list of host names, or, with hosts, a URL is not https on one of them.