Cloudinary Blog

New Svelte Framework SDK for Cloudinary

New Svelte Framework SDK for Cloudinary

Back in April, Cloudinary made available on npm an alpha version of its components library for Svelte, a release that’s a wonderful addition to Cloudinary’s suite of client-side SDKs: React, Vue, and Angular. Those three front-end SDKs offer simple yet comprehensive optimization, transformation, and delivery capabilities for images and videos—features that you can tailor to automatically apply the best-fitting formats for all devices and browsers.

The Svelte SDK offers all those capabilities to Svelte developers through two robust components, Images and Videos.

Note
For details on Cloudinary’s next-generation developer SDKs, see this recent post.

The Image Component

With the Image component, you can display and transform images stored on Cloudinary, for example, by having Cloudinary generate an HTML <img> element whose source has been cropped as a circle and centered on someone’s face (see the photo below).

If you do not specify any image format, Cloudinary automatically applies the most suitable one for the browser. Here’s a code example:

Copy to clipboard
<Image
      cloud_name="demo"
      public_id="woman"
      transformation="{{
 width: 400,
 height: 400,
 gravity: 'face',
 radius: 'max',
 crop: 'crop' 
    }}"
/>

The generated HTML <img> element looks like this:

The Video Component

Similarly, the Video component enables you to display and transform videos stored on Cloudinary. For example, in automatically adding a poster image for a video, the Video component generates an HTML <video> element for a source that has been rotated by 20 degrees. If you don’t specify a video format, the component automatically adds fallback sources, as in this example:

Here’s the generated HTML <video> element:

Copy to clipboard
     <video
       controls="true"
       muted="true"
       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>

Upcoming Enhancements

Keep in mind that, even though the Svelte SDK components are fully functional, this is an alpha version only. That’s because our roadmap for the future encompasses major improvements to our core JavaScript library, which will affect all the client SDKs that rely on that library.

Here are the main upcoming enhancements:

  • A lighter modular bundle for importing used modules only.
  • New actions-based transformation capabilities for defining media transformations in a simpler manner.
  • An advanced Image component with built-in lazy loading and placeholder capabilities along with support for accessibility.

If you’re new to Cloudinary, to get started, just sign up for a free account, and do check out the new Svelte SDK on npm and its code repository on GitHub.

Recent Blog Posts

Creating an API With Python Flask to Upload Files to Cloudinary

Code

Cloudinary offers SDKs for many programming languages and frameworks. Even though it also offers an Upload API endpoint for both back-end and front-end code, most developers find the SDKs very helpful. If you're working with a powerful back-end framework like Python Flask, you'll be happy to hear that a Python SDK is now available.
This tutorial walks you through the process of building an API to upload images to Cloudinary. You can also upload other file types, including video and even nonmedia files, with the API.

Read more
How to Use the Cloudinary Media Editor Widget

At Cloudinary, we manage the entire pipeline of media assets for thousands of customers of varying sizes from numerous verticals.

As part of our commitment to support the entire flow of media assets, we are now introducing an intuitive media editing widget: an out­-of­-the-­box, interactive UI providing your users with a set of common image editing actions for immediate use on your website or web app. The widget is interactive and simple, built on Cloudinary's transformation capabilities, and requiring only a few lines of code to integrate. Afterwards, you can seamlessly and effortlessly add content to your site or app with no need for in-house image editing capabilities.

Read more
Shoppable Video Is Becoming Popular in E-Commerce

As pandemic restrictions necessitated, many shopping trips in 2020 took place outside the traditional brick-and-mortar store, or at least void of the physical aisle-browsing experience. Same-day curbside pickup became a safe and convenient alternative, and e-commerce transactions skyrocketed as consumers shopped online. In fact, Digital Commerce 360 estimates that, compared to 2019, e-commerce transactions grew by more than 40% last year.

Read more
Enhance Your Travel Site With Cloudinary in Anticipation of a Return to New Normal

Read more
The Benefits of Headless DAMs

Headless is not a buzzword anymore. In fact, the concept of headless architecture is gaining momentum due to the flexibility it offers for composing new experiences and for tackling the undue complexity of an ever-evolving technology stack. That’s because while the evolution of the martech landscape has enabled disruptive, digital innovations, the approach of buying point solutions for solving specific challenges can expose companies to the complicated nature of new technologies, systems, and platforms.

Read more