# @forzoom/thumbnail

> ```typescript import Vue from 'vue'; import Thumbnail from '@forzoom/thumbnail';

Latest version **0.2.0** (published 2020-04-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @forzoom/thumbnail
pnpm add @forzoom/thumbnail
yarn add @forzoom/thumbnail
bun add @forzoom/thumbnail
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-04-22 |
| First published | 2019-01-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 54.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | forzoom |

## Links

- npm: https://www.npmjs.com/package/@forzoom/thumbnail
- npm.io page: https://npm.io/package/@forzoom/thumbnail

## Recent versions

- 0.2.0 (latest) — 2020-04-22
- 0.1.1 — 2020-02-28
- 0.1.0 — 2020-02-03
- 0.0.6 — 2020-02-03
- 0.0.5 — 2019-08-06
- 0.0.4 — 2019-08-05
- 0.0.3 — 2019-06-05
- 0.0.2 — 2019-05-10
- 0.0.1 — 2019-01-16

## README

## Usage

```typescript
import Vue from 'vue';
import Thumbnail from '@forzoom/thumbnail';

const imageFilter = Thumbnail.generateImageFilter({
    bed: {
        aliyun: 'https://aliyun.example.com',
    },
    isAliyun(listener: ImageFilterListener, options: ImageFilterOptions) {
        return /aliyun.example.com/.test(listener.src);
    },
})

Vue.use(Thumbnail, {
    imageFilter,
    enterClass: 'add-blur',
    leaveClass: 'transition-blur',
});
```

```css
.add-blur {
    transition: 0.3s filter, 0.3s -webkit-filter;
    -webkit-filter: blur(4px);
    filter: blur(4px);
}
// 图片模糊第二层
.transition-blur {
    -webkit-filter: blur(0px);
    filter: blur(0px);
}
```

<hr>

### 使用data-width
```html
<img v-thumbnail="https://aliyun.example.com/test.jpg" data-width="100" />
```
生成内容(以阿里云为例)
```html
<img src="https://aliyun.example.com/test.jpg?x-oss-process=image/resize,w_100" />
```
需要配置
```typescript
const imageFilter = Thumbnail.generateImageFilter({
    isAliyun(listener: ImageFilterListener, options: ImageFilterOptions) {
        return /aliyun.exmaple.com/.test(listener.src);
    },
});
Vue.use({
    imageFilter,
});
```

<hr>

### 让thumbnail自动添加域名
```html
<img v-thumbnail="/test.jpg" />
```
生成内容
```html
<img src="https://aliyun.example.com/test.jpg" />
```
需要配置
```typescript
const imageFilter = Thumbnail.generateImageFilter({
    bed: {
        aliyun: 'https://aliyun.example.com',
        qiniu: 'https://qiniu.example.com',
        default: 'https://aliyun.example.com', // 当没有域名是将默认使用default对应的域名
    },
});
Vue.use({
    imageFilter,
});
```
选择不同的域名，使用data-bed
```html
<img v-thumbnail="/test.jpg" data-bed="qiniu" />
```
生成内容
```html
<img src="https://qiniu.example.com/test.jpg" />
```

<hr>

使用data-thumbnail-width将触发thumbnail的逻辑，将使用**data-thumbnail-width**的值替换**data-width**的值
```html
<img v-thumbnail="example.jpg" data-thumbnail-width="100" />
```

## requirement

1. 依赖于core-js@3
2. 依赖于url

## Roadmap

1. doTransform不需要由ThumbnailPluginOptions.doTransform提供

---
_Source: https://npm.io/package/@forzoom/thumbnail · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
