An object where the keys are widths (in pixels) and the values are URLs for the images.
A srcSet
string, where each image URL is followed by its width (e.g., "640w").
imageSizesToSrcSet({
640: '/640.jpg',
750: '/750.jpg',
1024: '/1024.jpg',
1440: '/1440.jpg',
});
// => "/640.jpg 640w, /750.jpg 750w, /1024.jpg 1024w, /1440.jpg 1440w"
Transforms an object of image sizes into a
srcSet
string suitable for responsive images using thesrcSet
attribute.Each key in the
sizes
object represents a width in pixels, and the associated value is the image URL.