Configuration options for enabling and managing asset versioning in Cloudinary.
Type Definition
export type CloudinaryVersioningOptions = {
enabled?: boolean;
autoInvalidate?: boolean;
storeHistory?: boolean;
};
Properties
Whether to enable versioning support.
Whether to automatically invalidate old versions in CDN.
Whether to store version history in PayloadCMS.
Usage Examples
Enable All Versioning Features
import { cloudinaryStorage } from 'payload-cloudinary';
export default buildConfig({
plugins: [
cloudinaryStorage({
collections: {
media: true,
},
config: {
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
},
versioning: {
enabled: true,
autoInvalidate: true,
storeHistory: true,
},
}),
],
});
Basic Versioning Without History
import { cloudinaryStorage } from 'payload-cloudinary';
export default buildConfig({
plugins: [
cloudinaryStorage({
collections: {
media: true,
},
config: {
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
},
versioning: {
enabled: true,
autoInvalidate: false,
storeHistory: false,
},
}),
],
});
Versioning with Auto-Invalidation Only
import { cloudinaryStorage } from 'payload-cloudinary';
export default buildConfig({
plugins: [
cloudinaryStorage({
collections: {
media: true,
},
config: {
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET,
},
versioning: {
enabled: true,
autoInvalidate: true,
},
}),
],
});
How It Works
When versioning is enabled:
- enabled: Activates Cloudinary’s built-in versioning feature, allowing you to track different versions of the same asset
- autoInvalidate: Automatically purges cached versions from the CDN when a new version is uploaded, ensuring users always see the latest version
- storeHistory: Maintains a complete version history within PayloadCMS, allowing you to track and reference previous versions of assets