Migrate to v2
v2 is a near ground-up rewrite of svelte-cloudinary, including significant type improvements. This will undoubtedly cause many minor typing issues that would be impractical to cover in this guide. We’ll cover the major changes here that you can easily check for and change, and for the type errors, we recommend running svelte-check on your codebase. We hope that this rewrite will make it much easier for us to maintain this library into the future, especially with Svelte 5 on the horizon. If there is anything we’ve missed, or you have any issues, then let us know. We’ll keep updating this guide as needed to make it as frictionless as possible!
Configuration
The following environment variables have been renamed, the old names will be removed in the next major version:
| Old Name | New Name | Description |
|---|---|---|
VITE_PUBLIC_CLOUDINARY_CLOUD_NAME | VITE_CLOUDINARY_CLOUD_NAME | Your Cloudinary cloud name |
VITE_PUBLIC_CLOUDINARY_API_KEY | VITE_CLOUDINARY_API_KEY | API key for use with the upload widget |
Read more about Configuring Svelte Cloudinary here, including the new configureCloudinary function.
CldImage
transformations
transformations has been deprecated in favour of namedTransformations and will be removed in the next version.
CldOgImage
The alt prop is now required.
CldUploadWidget
Events
The onUpload event has now been deprecated, and will be removed in the next major version. You should migrate to onSuccess, which has a similar behaviour.
CldVideoPlayer
playerRef
The playerRef prop has been renamed to player, and is still readonly.
videoRef
The videoRef prop has been renamed to videoElement, and is still readonly.
Version Prop
The version prop has been removed and is now controlled and updated internally.
getCldImageUrl
The GetCldImageUrl, GetCldImageUrlOptions, GetCldImageUrlConfig, and GetCldImageUrlAnalytics types were removed. You can import ImageOptions, ConfigOptions, and AnalyticsOptions from @cloudinary-util/url-loader if you need these.
getCldOgImageUrl
The GetCldOgImageUrl type was removed. You can import ImageOptions, ConfigOptions, and AnalyticsOptions from @cloudinary-util/url-loader if you need these.
Dependencies
The utility libraries we use had some breaking changes, as well as new features:
| Library | Old Version | New Version | |
|---|---|---|---|
@cloudinary-util/url-loader | v3 | v5 | Changelog |
@cloudinary-util/util | v2 | v3 | Changelog |
@cloudinary-util/types | n/a | v1 | Changelog |