Builds resized image URLs on the Lynkow image transformation service,
accessible via lynkow.media. It makes no request and works on the server
and in the browser. It accepts original Lynkow media URLs and URLs it already
transformed.
Access via: lynkow.media
Methods
2 methods
srcset
srcset(imageUrl: string | null | undefined, options: SrcsetOptions): stringBuilds a srcset attribute value from a Lynkow image URL, with one
transformed URL per width. Returns an empty string for null, undefined
or a URL that is not a Lynkow media URL.
Parameter | Type | Description |
|---|---|---|
|
| Image URL from the API, such as |
|
|
|
Returns: string
const srcset = lynkow.media.srcset(article.featuredImage, { widths: [480, 960], fit: 'cover' })
const img = `<img src="${article.featuredImage}" srcset="${srcset}" sizes="100vw" alt="" />`transform
transform(imageUrl: string | null | undefined, options: TransformOptions): stringBuilds one transformed URL from a Lynkow image URL, for a thumbnail or any
fixed size. Returns a URL that is not a Lynkow media URL unchanged, and an
empty string for null or undefined.
Parameter | Type | Description |
|---|---|---|
|
| Image URL from the API, such as |
|
| Size, |
Returns: string
const thumb = lynkow.media.transform(content.featuredImage, { w: 400, h: 300, fit: 'cover' })