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

sanity-plugin-cloudinary

v2.1.4

Published

Cloudinary integration for Sanity Studio.

Downloads

25,169

Readme

sanity-plugin-cloudinary

Installation

pnpm add sanity-plugin-cloudinary

or

npm install --save sanity-plugin-cloudinary

or

yarn add sanity-plugin-cloudinary

Usage

There are three plugins in this package:

  • cloudinaryAssetSourcePlugin - use this if you intend to serve Cloudinary images from the Sanity CDN
  • cloudinarySchemaPlugin - use this if you intend to serve Cloudinary images from the Cloudinary CDN
  • cloudinaryReferencePlugin - use this if you want to reference Cloudinary assets as document references

Also see notes below on how Cloudinary config should be provided.

Cloudinary as a Sanity asset

Add Cloudinary as an asset source to all images

import {defineConfig} from 'sanity'
import {cloudinaryAssetSourcePlugin} from 'sanity-plugin-cloudinary'

export default defineConfig({
  /*...*/
  plugins: [cloudinaryAssetSourcePlugin()],
})

Fine tune image sources

import {defineConfig} from 'sanity'
import {cloudinaryImageSource} from 'sanity-plugin-cloudinary'

export default defineConfig({
  /*...*/
  form: {
    image: {
      assetSources: (previousAssetSources, context) => {
        if (context.currentUser?.roles.includes('cloudinaryAccess')) {
          // appends cloudinary as an asset source
          return [...previousAssetSources, cloudinaryImageSource]
        }
        if (context.currentUser?.roles.includes('onlyCloudinaryAccess')) {
          // only use cloudinary as an asset source
          return [cloudinaryImageSource]
        }
        // don't add cloudinary as an asset source
        return previousAssetSources
      },
    },
  },
})

Cloudinary assets

import {defineConfig} from 'sanity'
import {cloudinarySchemaPlugin} from 'sanity-plugin-cloudinary'

export default defineConfig({
  /*...*/
  plugins: [cloudinarySchemaPlugin()],
})

Now you can declare a field to be cloudinary.asset in your schema

    {
      type: "cloudinary.asset",
      name: "image",
      description: "This asset is served from Cloudinary",
    }

Cloudinary Reference Assets

This plugin mode allows you to store Cloudinary assets as document references, which can be useful for reusing the same asset across multiple documents.

import {defineConfig} from 'sanity'
import {cloudinaryReferencePlugin} from 'sanity-plugin-cloudinary'

export default defineConfig({
  /*...*/
  plugins: [cloudinaryReferencePlugin()],
})

Now you can declare a field to be a reference to a Cloudinary asset:

{
  type: "cloudinaryAssetReference",
  name: "image",
  description: "This is a reference to a Cloudinary asset document",
}

The plugin creates and maintains document references automatically. When you select an asset through the Cloudinary Media Library, it will:

  1. Create a cloudinaryAssetDocument if the asset doesn't exist yet in your dataset
  2. Update the asset if it already exists
  3. Store a reference to the asset document in your current document

This approach is particularly useful for:

  • Reusing the same assets across multiple documents
  • Updating assets in one place and having the changes reflected everywhere
  • Managing assets separately from the content that uses them

Config

Includes easy configuration of your cloudname and api key, stored safely in your dataset as a private document.

Uses Cloudinary media library for selecting assets and transformations

In arrays

If you use this type in an array, you will have additional array functions for adding multiple assets at once, and for configuring the connection to Cloudinary.

{
  type: "array",
  name: "cloudinaryList",
  description: "This asset is served from Cloudinary",
  of: [{ type: "cloudinary.asset" }]
}

Content

Here is an example of which data is stored on your document after selecting an asset.

{
  "public_id": "29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x",
  "resource_type": "image",
  "type": "upload",
  "format": "jpg",
  "version": 1616474653,
  "url": "http://res.cloudinary.com/dzwiku20l/image/upload/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
  "secure_url": "https://res.cloudinary.com/dzwiku20l/image/upload/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
  "width": 2400,
  "height": 1344,
  "bytes": 547710,
  "duration": null,
  "tags": [],
  "context": {
    "custom": {
      "alt": "alternative text for image"
    }
  },
  "created_at": "2021-03-23T04:44:13Z",
  "access_mode": "public",
  "_version": 1,
  "_type": "cloudinary.asset"
}

Note: The _version in the data here refers to the schema version of this plugin, should the way it stores the data from Cloudinary change in the future.

Transformations

You can create a transformation when selecting the asset, and this information is previewed and stored

{
  "public_id": "29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x",
  "resource_type": "image",
  "type": "upload",
  "format": "jpg",
  "version": 1616474653,
  "url": "http://res.cloudinary.com/dzwiku20l/image/upload/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
  "secure_url": "https://res.cloudinary.com/dzwiku20l/image/upload/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
  "width": 2400,
  "height": 1344,
  "bytes": 547710,
  "duration": null,
  "tags": null,
  "context": {
    "custom": {
      "alt": "alternative text for image"
    }
  },
  "created_at": "2021-03-23T04:44:13Z",
  "derived": [
    {
      "url": "http://res.cloudinary.com/dzwiku20l/image/upload/a_45/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
      "secure_url": "https://res.cloudinary.com/dzwiku20l/image/upload/a_45/v1616474653/29b4a88182b4cb50330011d23a29bcb371bd5886-2400x1344_lzcx7x.jpg",
      "raw_transformation": "a_45"
    }
  ],
  "access_mode": "public",
  "_version": 1,
  "_type": "cloudinary.asset"
}

Video

Video assets gets a video player preview in the Studio

{
  "public_id": "Make_it_happen_together.-WWa8qtgD0f0_nucpr9",
  "resource_type": "video",
  "type": "upload",
  "format": "mp4",
  "version": 1616474928,
  "url": "http://res.cloudinary.com/dzwiku20l/video/upload/v1616474928/Make_it_happen_together.-WWa8qtgD0f0_nucpr9.mp4",
  "secure_url": "https://res.cloudinary.com/dzwiku20l/video/upload/v1616474928/Make_it_happen_together.-WWa8qtgD0f0_nucpr9.mp4",
  "width": 1920,
  "height": 1080,
  "bytes": 3937717,
  "duration": 24.1,
  "tags": [],
  "metadata": [],
  "created_at": "2021-03-23T04:48:48Z",
  "access_mode": "public",
  "_version": 1,
  "_type": "cloudinary.asset"
}

License

MIT-licensed. See LICENSE.