Skip to content

Conversation

pgurley
Copy link

@pgurley pgurley commented May 1, 2025

Add Cloudinary Reference Asset Plugin

Overview

This PR introduces a new plugin mode that allows storing Cloudinary assets as document references. This approach enables reusing the same assets across multiple documents and managing them centrally.

New Features

  • Added cloudinaryReferencePlugin for registering all required schema types
  • Added cloudinaryAssetDocument type to store Cloudinary assets as documents
  • Added cloudinaryAssetReference type to reference these asset documents
  • Created custom input component for selecting and managing referenced assets
  • Updated README with documentation for the new reference approach

Changes

  • Enhanced openMediaSelector utility to support showing/hiding callbacks, so the button is disabled and shows a loading state vs being able to click it multiple times.
  • Added width/height to CloudinaryAsset type
  • Fixed typo in cloudinaryAssetSourcePlugin name

Benefits

  • Assets can be reused across multiple documents
  • Asset updates propagate to all references (We have a webhook that handles CRUD events from Cloudinary back to Sanity)
  • Centralizes asset management
  • Reduces data duplication in the dataset

Testing

Tested functionality with various asset types (images, videos) and verified that references are correctly created, updated, and displayed in the Sanity Studio interface.

Screenshots

No asset selected
Screenshot 2025-05-01 at 12 56 19 PM

Asset (as image) selected
Screenshot 2025-05-01 at 12 57 38 PM

View of component's data structure in article model
Screenshot 2025-05-01 at 1 22 57 PM

View of documents stored in sanity
Screenshot 2025-05-01 at 1 00 39 PM

Data model of stored document

Screenshot 2025-05-01 at 1 01 36 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants