Skip to content
BasiX Media

CDN URLs & image variants

How addresses are built, and how to resize on the fly.

On this page

Every file has a public address:

text
https://cdn.basix.media/<publicId>/<path>
  • publicId: 8 lowercase characters, the same for every file of your account. Get it from GET /api/v1/me or the dashboard.
  • path: the path you chose at upload, lowercased.

So your code can build the address instead of asking the API:

const CDN = 'https://cdn.basix.media/a7k2m9x4' const itemImage = (name) => `${CDN}/items/${name}.png`

Custom domain. On plans that include it, point a CNAME (for example cdn.myserver.com) at cname.basix.media and add the domain in Dashboard → Domain. Files then also answer at https://cdn.myserver.com/<path>, without the publicId.

Caching. Files are served with Cache-Control: public, max-age=300, an ETag, Access-Control-Allow-Origin: * and range requests (video seeking works). After you replace a file, expect the new version everywhere within 5 minutes.

Missing images. If you set a placeholder image in Dashboard → Files, a missing image address under your publicId returns that placeholder instead of a 404.

Thumbnails and variants

Add ?w= (width) and/or ?f= (format) to an image address on cdn.basix.media:

text
https://cdn.basix.media/a7k2m9x4/avatars/john.png original https://cdn.basix.media/a7k2m9x4/avatars/john.png?w=128 128 px wide, WebP https://cdn.basix.media/a7k2m9x4/avatars/john.png?w=128&f=png
  • Works on .png, .jpg, .jpeg, .webp, .avif. GIF, video and audio are served as uploaded, the query is ignored.
  • Widths snap up to this ladder: 16, 32, 64, 96, 128, 160, 192, 256, 320, 384, 448, 512, 640, 768, 896, 1024, 1280, 1536, 2048. ?w=400 gives 448.
  • Formats: webp (default), jpeg (or jpg), png.
  • Images are never enlarged. The applied width is in the X-Basix-Width header.
  • The original is never modified. Variants are generated on first request, then cached.
  • An invalid value (for example ?w=abc or ?f=gif) answers 400.
  • Variants are only served on cdn.basix.media, not on custom domains.

Try it on your own server

Create a free account and your API key is ready in about two minutes. 3 GB included, bandwidth never billed, no card needed.

Create a free account
CDN URLs & image variants — Standalone docs — BasiX