# @betttercms/image-url

> Build optimized BetterCMS image URLs with a chainable, immutable builder.

Latest version **0.1.0** (published 2026-06-16) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @betttercms/image-url
pnpm add @betttercms/image-url
yarn add @betttercms/image-url
bun add @betttercms/image-url
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2026-06-16 |
| First published | 2026-06-16 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 24.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | flowttrix |

## Links

- npm: https://www.npmjs.com/package/@betttercms/image-url
- npm.io page: https://npm.io/package/@betttercms/image-url

## Recent versions

- 0.1.0 (latest) — 2026-06-16

## README

# @betttercms/image-url

Chainable, immutable builder for optimized BetterCMS image URLs — the
`@sanity/image-url` of BetterCMS. Zero runtime dependencies; assembles URLs
against the media transform endpoint (`GET /media/:id?w&h&format&quality&fit&dpr`).

## Install

```bash
npm install @betttercms/image-url
```

## Usage

```ts
import imageUrlBuilder from "@betttercms/image-url";

const urlFor = imageUrlBuilder({ baseUrl: "https://media.bettercms.ai" });

// From an asset id, a MediaAsset object, or an existing media URL:
urlFor(asset).width(800).format("webp").quality(80).url();
// → https://media.bettercms.ai/media/<id>?w=800&format=webp&quality=80
```

One-shot helper:

```ts
import { imageUrl } from "@betttercms/image-url";
imageUrl(asset).size(400, 300).fit("cover").dpr(2).url();
```

## Builder methods

| Method | Param → query |
| --- | --- |
| `.width(n)` / `.height(n)` | `w` / `h` (rounded) |
| `.size(w, h)` | `w` + `h` |
| `.format(f)` | `format` (`webp`\|`jpeg`\|`png`\|`avif`; `jpg`→`jpeg`) |
| `.quality(q)` | `quality` (clamped 1–100) |
| `.fit(f)` | `fit` (`cover`\|`contain`\|`fill`\|`inside`\|`outside`) |
| `.dpr(d)` | `dpr` (clamped 1–3; omitted when 1) |
| `.url()` / `.toString()` | render |

`baseUrl` defaults to `https://media.bettercms.ai`. Every method returns a new
builder, so chains are safe to fork.

---
_Source: https://npm.io/package/@betttercms/image-url · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
