DEPRECATED
This package has been deprecated, see https://github.com/cloudinary-community/svelte-cloudinary
Cloudinary is a cloud service that offers a solution to a web application's entire image and video management pipeline.
Easily upload images to the cloud. Automatically perform smart image resizing, cropping and conversion without installing any complex software. Integrate Facebook or Twitter profile image extraction in a snap, in any dimension and style to match your website’s graphics requirements. Images are seamlessly delivered through a fast CDN, and much much more.
Cloudinary offers comprehensive APIs and administration capabilities and is easy to integrate with any web application, existing or new.
Cloudinary provides URL and HTTP based APIs that can be easily integrated with any Web development framework.
Install the package using the following command:
npm i @cloudinary/svelte
-
Include the cloudinary-svelte package in your code, for example:
import { Image, Video } from '@cloudinary/svelte';
-
Add an Image or Video component in your html:
<Image.../> <Video.../>
-
Pass the required parameters to the component:
// cloud_name - is your Cloudinary account // public_id - is the asset identifier in your Cloudinary account // (usually the file name without a file extension) <Image cloud_name="demo" public_id="sample" …{any <img> tag attributes}/>
-
To fetch a transformed asset, you can pass a transformation parameter to the Image or Video components.
For example, this transformation will alter the image URL to fetch the same image scaled to 200px:transformation = “{ width: 200, crop: ‘scale’ }”
The transformation object can be an array of transformations,
where each transformation is applied to the result of the previous transformation, for example:transformation="{[ { width: 400, height: 400, gravity: 'face', radius: 'max', crop: 'crop' }, { width: 200, crop: 'scale' } ]}"
<script>
import { Image, Video } from '@cloudinary/svelte';
</script>
<style>
main {
text-align: center;
padding: 1em;
max-width: 240px;
margin: 0 auto;
}
</style>
<main>
<Image
cloud_name="demo"
public_id="sample"
transformation="{[
{ width: 400, height: 400, gravity: 'face', radius: 'max', crop: 'crop' },
{ width: 200, crop: 'scale' }
]}"
/>
<Video
cloud_name="demo"
public_id="dog"
transformation={{ angle: 20 }}
controls
muted
/>
</main>
The video component will generate this html: (See actual video here)
<video controls muted poster="http://res.cloudinary.com/demo/video/upload/a_20/dog.jpg">
<source src="http://res.cloudinary.com/demo/video/upload/a_20/dog.webm" type="video/webm">
<source src="http://res.cloudinary.com/demo/video/upload/a_20/dog.mp4" type="video/mp4">
<source src="http://res.cloudinary.com/demo/video/upload/a_20/dog.ogv" type="video/ogg">
</video>
The Cloudinary Documentation can be found at: http://cloudinary.com/documentation
Additional resources are available at:
You can open an issue through GitHub.
Contact us at http://cloudinary.com/contact.
Stay tuned for updates, tips and tutorials: Blog, Twitter, Facebook.
Impact the product, hear updates, test drive new features and more! Join here.
Released under the MIT license.