/api/media/{photoId} with your transform params as query string. On first access the server processes the image and caches the result permanently. Subsequent requests return the cached file.
This is the only SDK method that does not make a network request. It builds and returns a string immediately.
Parameters
UUID of the photo. Obtain it from
getPhotos() or getCollection().Optional transform options. Server defaults apply when omitted.
MediaUrlOptions
Target width in pixels (1–5000). Height scales proportionally unless
h is also set.Target height in pixels (1–5000). Width scales proportionally unless
w is also set.Output format. One of
webp, jpeg, or avif.Quality from 1 (lowest) to 100 (highest).
Scaling mode when both
w and h are provided.| Value | Behavior |
|---|---|
cover | Crops to fill the box exactly |
contain | Letterboxes to fit within the box |
fill | Stretches to fill the box exactly |
Returns
A URL string, for example:Examples
transforms.ts
Caching
The server stores the transformed image after the first request. All subsequent calls with the same params skip processing entirely.Pre-generated versions vs. getMediaUrl
| Situation | Approach |
|---|---|
| Standard grid / detail / download sizes | photo.versions.find(v => v.versionType === "webp_thumb")?.url |
| Custom size or crop | client.getMediaUrl(photo.id, { w: 400 }) |
| AVIF output | client.getMediaUrl(photo.id, { format: "avif" }) |
| OG / social preview crop | client.getMediaUrl(photo.id, { w: 1200, h: 630, fit: "cover" }) |
getMediaUrl only when the three built-in versions don’t cover your case.