npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@airdraft/plugin-media

v0.2.13

Published

Airdraft media plugin — image upload, optimisation, CDN

Readme

@airdraft/plugin-media

Media management plugin for Airdraft. Adds binary file upload/storage, a browsable media library, and automatic URL resolution for image and media schema fields.

Installation

npm install @airdraft/plugin-media

You also need a storage adapter: @airdraft/media-adapter-local for local development, @airdraft/media-adapter-files-sdk for S3 / Airdraft Cloud, or @airdraft/media-adapter-github for repo-backed media files.

Usage

withAutoMedia (recommended)

Auto-selects the right adapter based on environment variables. Uses the Files SDK (S3) when AWS_S3_BUCKET_NAME is set, otherwise falls back to the local adapter. GitHub repo-backed media is available via explicit selection with storageBackend: 'github' or AIRDRAFT_MEDIA_ADAPTER=github.

import { withAutoMedia } from '@airdraft/plugin-media'

const media = await withAutoMedia({ storageAdapter: adapter })

export default defineConfig({
  adapter,
  plugins: [media],
})

GitHub backend example:

const media = await withAutoMedia({
  storageAdapter: adapter,
  storageBackend: 'github',
})

This stores binary media directly in the repository using the same GitHub App credentials or token-relay environment variables already used for content storage.

withMedia (manual)

Explicit adapter selection:

import { withMedia } from '@airdraft/plugin-media'
import { LocalMediaAdapter } from '@airdraft/media-adapter-local'

const media = withMedia({
  adapter: new LocalMediaAdapter({ root: './public' }),
  storageAdapter: adapter,          // content adapter for sidecar metadata
  prefix: 'uploads',               // key prefix for uploaded files
  allowedTypes: ['image/jpeg', 'image/png', 'image/webp'],
  maxSize: 5 * 1024 * 1024,        // 5 MB
})

Options

| Option | Type | Default | Description | |---|---|---|---| | adapter | MediaAdapter | required | Binary storage adapter | | storageAdapter | StorageAdapter | — | Content adapter for sidecar metadata (enables full library mode) | | prefix | string | 'uploads' | Key prefix for uploaded files | | allowedTypes | string[] | ['image/jpeg', 'image/png', 'image/webp', 'image/gif', 'image/svg+xml'] | Accepted MIME types | | maxSize | number | — | Max upload size in bytes |

API Routes

The plugin registers the following routes on the CMS handler:

| Method | Path | Description | |---|---|---| | POST | /media/upload | Upload a file (multipart/form-data) | | GET | /media | List media items (supports prefix, limit, cursor) | | GET | /media/:key | Get a single media item's metadata | | PATCH | /media/:key | Update media metadata (alt, caption, title, tags) | | DELETE | /media/:key | Delete a file and its sidecar | | GET | /media/:key/url | Resolve a fresh signed URL for a key |

transformEntry hook

The plugin injects companion fields for every image and media field in a collection when an entry is read:

| Field type | Injected companions | |---|---| | image or media (single) | {field}_url: string, {field}_media: MediaItem | | media (multiple) | {field}_urls: string[], {field}_medias: MediaItem[] |

URLs are resolved fresh on every read (pre-signed S3 URLs are always current).

Changelog

See CHANGELOG.md.