Service for building optimized image URLs using Cloudflare Image Transformations.
Accessible via lynkow.media. This is a pure utility service (no API calls, no
caching) that constructs Cloudflare /cdn-cgi/image/ URLs from Lynkow media URLs.
Works on both server and browser. Handles both original URLs (/sites/...) and
already-transformed URLs (/cdn-cgi/image/...), re-extracting the original path
when needed.
Access via: lynkow.mediaHelper
Methods
2 methods
srcset
srcset(imageUrl: string | null | undefined, options: SrcsetOptions): stringGenerates an HTML srcset attribute value from a Lynkow image URL, suitable
for use in an <img srcset="..."> or <source srcset="..."> tag. Produces
one Cloudflare Image Transformation URL per width breakpoint.
Parameter | Type | Description |
|---|---|---|
|
| Original image URL from the Lynkow API (e.g. |
|
| Configuration for the srcset:<br> - |
Returns: string
// Build a responsive <img> tag with multiple widths
const srcsetValue = lynkow.media.srcset(article.featuredImage, {
widths: [480, 768, 1024, 1440],
fit: 'cover',
quality: 85,
})
const imgTag = `<img srcset="${srcsetValue}" sizes="(max-width: 768px) 100vw, 50vw" alt="${article.title}" />`transform
transform(imageUrl: string | null | undefined, options: TransformOptions): stringGenerates a single Cloudflare Image Transformation URL from a Lynkow image URL. Useful for thumbnails, hero images, or any context where you need a specific size/format.
Parameter | Type | Description |
|---|---|---|
|
| Original image URL from the Lynkow API (e.g. |
|
| Transformation options:<br> - |
Returns: string
// Build an optimized thumbnail URL for a product card
const thumbUrl = lynkow.media.transform(product.image, {
w: 400,
h: 300,
fit: 'cover',
format: 'webp',
quality: 75,
})
document.querySelector('.product-thumb').src = thumbUrl