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

Generate Names With faker.js and Convert Them to Graphics With Cloudinary

The year was 1994. South Africa held its first fully representative democratic election, Netscape Navigator became the first commercially successful web browser. Coconuts Japan re-released EA Sports' MLBPA Baseball video game under the perhaps surprising title Fighting Baseball. Unlike MLBPA Baseball, which was licensed by the Major League Baseball (MLB), Fighting Baseball could not infringe on MLB trademarks, reference the National League or American League by name, or adopt actual team or player names.

Read more
Partner news: Cloudinary-Getty Images Integration

Supported by intelligent automation, Cloudinary serves as an effective conduit between media asset management and delivery so you can take maximum advantage of assets, compress workflows, and build and coordinate engaging and inspiring customer experiences. Through Cloudinary’s Digital Asset Management (DAM) solution, which employs the company’s innovative image and video APIs, creative and marketing teams can benefit from them, as well as from many AI-powered and automated capabilities. As a result, you can transform, optimize, and deliver media at scale on an intuitive UI.

Read more