# svelte-lazy-image-loader

> Shows a loading animation while loading an image.

Latest version **1.0.4** (published 2020-02-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install svelte-lazy-image-loader
pnpm add svelte-lazy-image-loader
yarn add svelte-lazy-image-loader
bun add svelte-lazy-image-loader
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2020-02-18 |
| First published | 2019-10-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 38.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Timo Zimmermann |
| Maintainers | timoz |
| Keywords | svelte, lazy, image, loader, placeholder |

## Links

- npm: https://www.npmjs.com/package/svelte-lazy-image-loader
- Repository: https://github.com/jz222/svelte-lazy-image-loader
- Homepage: https://github.com/jz222/svelte-lazy-image-loader#readme
- Issues: https://github.com/jz222/svelte-lazy-image-loader/issues
- npm.io page: https://npm.io/package/svelte-lazy-image-loader

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2020-02-18
- 1.0.3 — 2020-02-14
- 1.0.2 — 2020-02-05
- 1.0.1 — 2020-01-24
- 1.0.0 — 2019-10-03

## README

# Svelte Lazy Image Loader

Shows a loading animation while loading an imagine.

**Without placeholder animation:**

![enter image description here](https://i.imgur.com/aUQmZTs.gif)

**With placeholder:**

![enter image description here](https://i.imgur.com/aSlEjAN.gif)

## Install

*npm*

`npm i svelte-lazy-image-loader`

*yarn*

`yarn add svelte-lazy-image-loader`

## API

| Props             | Value                                                   |
|-------------------|---------------------------------------------------------|
| url               | image url as string                                     |
| alt               | alt text as string                                      |
| imageWidth        | width of the image as string. Defaults to 100%.         |
| imageHeight       | height of the image as string                           |
| placeholderWidth  | width of the placeholder as string. Defaults to 100%.   |
| placeholderHeight | height of the placeholder as string. Defaults to 400px. |
| styling           | CSS properties as string                                |

## Examples

Default placeholder:

```javascript
<script>
	import ImageLoader from 'svelte-lazy-image-loader';
</script>

<ImageLoader
	url="https://example.com/image.png"
	alt="example image"
	imageWidth="500px"
	imageHeight="200px"
	placeholderWidth="500px"
	placeholderHeight="200px"
	styling="margin-right: 1rem; padding: 1rem;"
/>
```

Custom placeholder:

```javascript
<script>
	import ImageLoader from 'svelte-lazy-image-loader';
</script>

<ImageLoader
	url="https://example.com/image.png"
	alt="example image"
	imageHeight="200px"
	placeholderHeight="200px"
>
	<div>loading</div>
</ImageLoader>
```

---
_Source: https://npm.io/package/svelte-lazy-image-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
