# images-size-loader

> an webpack loader for vue.js which can add the width and height to

Latest version **0.1.9** (published 2018-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install images-size-loader
pnpm add images-size-loader
yarn add images-size-loader
bun add images-size-loader
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.9 |
| Published | 2018-06-05 |
| First published | 2018-01-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | overarchingSky |
| Maintainers | overarchingsky |
| Keywords | image, images, images-size, size, loader, width, height, <img> |

## Links

- npm: https://www.npmjs.com/package/images-size-loader
- Repository: https://github.com/overarchingSky/images-size-loader
- Homepage: https://github.com/overarchingSky/images-size-loader#readme
- Issues: https://github.com/overarchingSky/images-size-loader/issues
- npm.io page: https://npm.io/package/images-size-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

- 0.1.9 (latest) — 2018-06-05
- 0.1.8 — 2018-04-23
- 0.1.7 — 2018-04-23
- 0.1.6 — 2018-04-20
- 0.1.5 — 2018-04-20
- 0.1.4 — 2018-04-20
- 0.1.3 — 2018-04-20
- 0.1.2 — 2018-01-15
- 0.1.1 — 2018-01-15
- 0.1.0 — 2018-01-15
- 0.0.3 — 2018-01-15
- 0.0.2 — 2018-01-12
- 0.0.1 — 2018-01-12

## README

[![npm](https://img.shields.io/npm/v/images-size-loader.svg)](https://www.npmjs.com/package/images-size-loader)

## images-size-loader for vue.js

an webpack loader for vue.js which can calculate the size of `<img>`'s src and add width and height as it's attribute.

### Usage

```
npm install images-size-loader --save-dev
...

module: {
  ...
  rules: [
        {
          test: /\.vue$/,
          use: [
            {
              loader: "vue-loader",
              options: vueLoaderConfig
            },
            {
              loader: "images-size-loader"
            }
          ]
        },
        ...

html:

添加 loading 属性，开启 loading 加载动画：<img loading src="****.png" />

添加 size-loading 属性，开启 loading 加载动画并自动读取图片尺寸：<img size-loading src="****.png" />
```

### example

before resolve:

```
<img
:src="require('images/b.gif')"
:srcset="require('images/b.gif') + ' 1x,'
+ require('images/logo.png') + ' 2x,'
+ require('images/a.gif') + ' 3x'"
sizes="(min-width:520px) 500px, 100%" alt="" />
```

after resolve:

```
<img
width=300 height=400
:src="require('images/b.gif')"
:srcset="require('images/b.gif') + ' 1x,'
+ require('images/logo.png') + ' 2x,'
+ require('images/a.gif') + ' 3x'"
sizes="(min-width:520px) 500px, 100%" alt="" />
```

### notices

the calculation of size is not According to the `<img>`'s srcset, but src, because that we don't know which one of image specificed is expected as the calculation image.So, if your `<img>` contains srcset, please point out one of them as src's value.\
In addition, once handled by images-size-loader, an special class named `_images-size-loader-loading` will be add on `<img>` , and when the `<img>`'s src loaded, it will be removed.\
Now, the class `_images-size-loader-loading` will only show a loading image, and it can be customized according to you.

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