Cloudinary Blog

Advanced Image Component for Cloudinary’s Angular SDKs

Advanced Image Component for Cloudinary’s Angular SDKs

With Cloudinary’s current client-side SDKs, such as React, Vue, and Angular, you can manage images in numerous amazing ways, for example, making use of media from Cloudinary for your project, transforming media, and enhancing the responsiveness of your site. A new and exciting feature in our Angular SDK, called the Advanced Image component, takes image management to the next level by handling many common front-end (FE) tasks, such as lazy loading, placeholding, accessibility, and, coming soon, zooming. Just ask the component to perform any of those tasks by adding the appropriate attributes and it’ll do the rest.

Webinar
How to Optimize for Page Load Speed

Read on for the details.

Lazy Loading

Lazy-loading an image means that you download and display the image only if necessary, such as when the viewer scrolls down and the image is about to enter the viewport, hence economizing load time.

All you need to do is add the attribute loading=“lazy” to your image’s cl-image tag, for example:

Copy to clipboard
<cl-image loading=”lazy” public-id=”kit” width=”500”></cl-image>

Afterwards, that image loads only when it is in the viewport.

Note
For Google Chrome, native lazy-loading, which has been available since Chrome 76, applies. For other browsers, we implemented lazy loading with the Intersection Observer API.

Placeholding

Image size affects website content’s load-time the most. To boost viewer experience, ensure that your images are of the smallest possible size.

An image’s placeholder is a much smaller, lower-quality version of the image to be displayed. A smart way to accelerate page loading is to first load a tiny, low-quality image as a placeholder, followed by the real image itself.

To make that happen, add placeholder as a nested attribute to your cl-image tag, as in this example:

Copy to clipboard
<cl-image loading=”lazy” public-id=”bear” width=”500”>
   <cl-placeholder type=”pixelate”></cl-placeholder>
<cl-image>

Several placeholder types are available, with the default being a lower-quality, blurred image. Here are the options along with their file sizes as compared to the original:

LQIP

We recommend that you adopt both placeholding and lazy loading for your images to ensure that the originals are downloaded only when necessary.

Support for Accessibility

All modern apps must support accessibility for the visually impaired, who can make use of widgets that enable them to customize apps to accommodate their viewing needs. How your app reacts to the customization is up to you, however.

A common approach is to change the app's theme to dark mode by tweaking the CSS. Nonetheless, that strategy misses an important aspect of the app: the images. To fully support accessibility, ensure that, when asked to change a page to dark mode, the related images also transform to a darker version. Simply add the attribute accessibility=“darkmode” to the cl-image tag.

You have four options to choose from: darkmode, colorblind, monochrome, and brightmode. The diagram below illustrates the differences.

accessibility

More in the Horizon

We'll soon add the zooming capability to the Advanced Image component, which will also be available for our React and Vue SDKs in the near future. In addition, we’ll keep improving the component and adding other features. Watch this space for the announcements and be sure to give Cloudinary a try for free!

Recap

Cloudinary's Advanced Image Component's automated capabilities for common FE tasks spell significant time savings and peace of mind for developers. High on our priority list is the component's availability for the React JavaScript SDK and the Vue.js JavaScript SDK. Additionally, we'll continue to stay alert to front-end needs and to enhance our image components with features geared toward easing the life of FE developers. That's a promise. Be sure to give Cloudinary a try!

Recent Blog Posts

Automatic Video Creation for Social Media at Scale

With video becoming increasingly popular, especially across social media, it’s as important as ever to ensure that your videos aren’t one of the hundreds that people just scroll on past. There’ve been a few successful techniques over the last couple of years to help with that, such as—

Read more
Uploading, Managing and Delivering PDFs With Cloudinary

The Portable Document Format (PDF) is a popular format developed by Adobe for delivering formatted text and images. A PDF file includes a complete description of all layout elements, including text, fonts, images and layers, ensuring that the file will look identical when opened on any device. The PDF format also has the big advantage of compressing high-quality files to a relatively small file size.

Read more
Share Your DAM Assets! New Visual Collections + Media Portal

If you've been working at home with young kids around during these “corona days”, you might have intuitively expected the last word of the title above to be "Toys" or "Candy"   😜. However, if you're a member of a creative team for a web site or software application, then you know how essential it is to have simple ways to share and collaborate on pre-production media assets.

Read more