1.2.0 • Published 9 months ago

@wernerglinka/cloudinaryimage v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

CloudinaryImage

A Web Component for Lazy Loading a Cloudinary Image

The CloudinaryImage component uses progressive image loading, e.g., display a low-resolution image initially and then replace it with a high-resolution image once it becomes visible in the viewport. To achieve this, the component uses the Intersection Observer API to detect when it is in the viewport. The component will also ensure that the image maintains its aspect ratio and is styled with the appropriate CSS to prevent layout shifts.

npm: version license: ISC

Installation

npm install cloudinaryimage

Usage

<cloudinary-image
  base="https://res.cloudinary.com/<your-cloud-name>/image/upload/"
  imageid="<your-image-id>"
  alt="Your alt text"
></cloudinary-image>

Attributes

AttributeDescriptionTypeDefault
baseThe base URL for your Cloudinary accountString
imageidThe image ID for your imageString
altThe alt text for your imageString

Styling

The component exposes the following CSS Custom Properties for styling: | Property | Description | Default | | -------- | ----------- | ------- | | --image-height | The height of the image | 100% |

The component will fill the available width. To control the height, you can set the --image-height CSS Custom Property. To cover the whole viewport for example:

cloudinary-image {
  --image-height: 100vh;
}

License

MIT

Author

Werner Glinka

1.2.0

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

10 months ago