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

Automation Frees Up PetRescue’s Staff to Help Pets Find Their Forever Homes

As we spend more time at home, many of us are adopting pets for the joy, companionship and a surprising range of health benefits. In Australia, where our nonprofit customer PetRescue is located, there’s a shortage of pets to adopt. Last August, the Guardian reported that dog shelters in Australia emptied and adoption fees for puppies were running as high as $AUS1800.

Read more
Cloudinary and Contentful Make Modern Content Management Easier

I am pleased to share that Cloudinary and Contentful have joined forces to further streamline the creation, processing, and delivery of online content through Cloudinary’s digital asset management (DAM) solution and advanced transformation and delivery capabilities for images and video. What’s more, the partnership delivers a headless approach to DAM. By leveraging APIs for media management tasks, marketers and developers alike benefit from an integrated stack of optimized assets for optimization and automation. As a result, page loads are fast and beautiful, and at scale—with less overhead and effort.

Read more
Introducing Cloudinary's Nuxt Module

Since its initial release in October 2016 by the Chopin brothers as a server-side framework that runs on top of Vue.js, Nuxt (aka Nuxt.js) has gained prominence in both intuitiveness and performance. The framework offers numerous built-in features based on a modular architecture, bringing ease and simplicity to web development. Not surprisingly, Nuxt.js has seen remarkable growth in adoption by the developer community along with accolades galore. At this writing, Nuxt has earned over 30K stars on GitHub and 96 active modules with over a million downloads per month. And the upward trend is ongoing.

Read more
How Quality and Quantity can go Hand in Hand

When it comes to quality versus quantity, you’ll often hear people say, “It’s the quality that counts, not the quantity”. While that’s true in many situations, there are also cases where you want both quality and quantity. You may have thousands of images on your website and you want them all to look great. This is especially important if your website allows users to upload their own content, for example, to sell their own products or services. You don't want their poor quality images to reflect badly on your brand.

Read more
Product Videos 101: What Makes Them Great?

A product’s benefits and usage, including its value proposition, features, and instructive details, are best demonstrated through video. Product-video types vary, depending on the funnel, channel, and audience, the most popular ones being demos, reviews, installation, and how-tos.

Read more