# vue-medialibrary

> A Vue component for the mdixon18/media-library

Latest version **1.0.11** (published 2019-06-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-medialibrary
pnpm add vue-medialibrary
yarn add vue-medialibrary
bun add vue-medialibrary
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2019-06-07 |
| First published | 2019-06-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 120.9 KB |
| Known vulnerabilities | 0 (+24 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Matthew Dixon |
| Maintainers | mdixon18 |

## Links

- npm: https://www.npmjs.com/package/vue-medialibrary
- Repository: https://github.com/mdixon18/vue-medialibrary
- Issues: https://github.com/mdixon18/vue-medialibrary/issues
- npm.io page: https://npm.io/package/vue-medialibrary

## Dependencies (6)

- [axios](https://npm.io/package/axios.md) ^0.18
- [vue-toasted](https://npm.io/package/vue-toasted.md) ^1.1.27
- [vue-infinite-loading](https://npm.io/package/vue-infinite-loading.md) ^2.4.4
- [@fortawesome/vue-fontawesome](https://npm.io/package/@fortawesome/vue-fontawesome.md) ^0.1.6
- [@fortawesome/fontawesome-svg-core](https://npm.io/package/@fortawesome/fontawesome-svg-core.md) ^1.2.18
- [@fortawesome/free-solid-svg-icons](https://npm.io/package/@fortawesome/free-solid-svg-icons.md) ^5.8.2

## Recent versions

- 1.0.11 (latest) — 2019-06-07
- 1.0.10 — 2019-06-07
- 1.0.9 — 2019-06-07
- 1.0.8 — 2019-06-07
- 1.0.7 — 2019-06-07
- 1.0.5 — 2019-06-07
- 1.0.4 — 2019-06-06
- 1.0.3 — 2019-06-06
- 1.0.2 — 2019-06-06
- 1.0.1 — 2019-06-06
- 1.0.0 — 2019-06-06

## README

# Vue Media Library
A vue component for the `mdixon18/media-library` package.

Laravel package can be found [here](https://github.com/mdixon18/media-library).

## Screenshots
**Manager**

![Manager](https://i.ibb.co/rcGNGwv/Screenshot-2019-06-07-at-11-57-03.png)

**Field**

![Empty field](https://i.ibb.co/c8H4MrT/Screenshot-2019-06-07-at-11-59-58.png)
![Field with image selected](https://i.ibb.co/vHGNvBb/Screenshot-2019-06-07-at-11-56-45.png)

## Installation
```
npm install --save vue-medialibrary
```

### Usage
#### Vue
```
    import  MediaLibrary  from  'vue-medialibrary';
    
    Vue.use(MediaLibrary, {
	    API_URL: 'http://urltoapp.tld'
    });
```
The API_URL is helpful if the application you are using the component in isn't the same application that the Laravel package is installed on. E.g. an SPA.

#### HTML Template

**Manager**
```
    <vue-medialibrary-manager v-if="show" />
```

**Field**
```
    <vue-medialibrary-field v-model="file" />
```

## Manager API
### Events
 - `@close` - this is used when the user has selected the close button in the manager, this should toggle off your original `v-if`. Naturally without a `v-if` this component will display at all times.
 - `@select` - this is primarily used within the field component so shouldn't be required, but it is triggered when the insert button has been selected on a media item. Only works if the `selectable` prop is set to `true`.
 - `@fail-to-find` - again primarily used within the field component so shouldn't be required. This will when a value is already set on the field component go and find that file so when the manager is opened that file is shown in the window on the right.  Only works if the `selectable` prop is set to `true`.

### Props
| Prop | Type | Default | Description
|--|--|--|--|
| `types` | `Object` | `{ images: true, files: true }` | Property controls whether both images and files can be toggled. Useful if you want to only use images or files. |
| `filetypes` | `Array` | `[]` | To limit the media to only certain file types. E.g. `[ 'png', 'jpg' ]`. |
| `selectable` | `Boolean` | `false` | Used by the field component but allows the media to be selectable, which also allows you to use the `@select` event. |
| `selected` | `String` | `null` | Used by the field component but allows you to pass in a filename which will then be automatically opened on the right window e.g. `test.jpg`. This will also cause the `@fail-to-find` event to be in operation.|


## Field API
### Events
 - `@close` - this is used when the user has selected the close button in the manager, this should toggle off your original `v-if`. Naturally without a `v-if` this component will display at all times.
 - `@select` - this is primarily used within the field component so shouldn't be required, but it is triggered when the insert button has been selected on a media item. Only works if the `selectable` prop is set to `true`.
 - `@fail-to-find` - again primarily used within the field component so shouldn't be required. This will when a value is already set on the field component go and find that file so when the manager is opened that file is shown in the window on the right.  Only works if the `selectable` prop is set to `true`.

### Props
| Prop | Type | Default | Description
|--|--|--|--|
| `types` | `Object` | `{ images: true, files: true }` | Property controls whether both images and files can be toggled within the manager. Useful if you want to only use images or files. |
| `filetypes` | `Array` | `[]` | To limit the media to only certain file types. E.g. `[ 'png', 'jpg' ]` in the manager. |
| `helper` | `String` | `null` | This allows you to put helpful message/text into the field. E.g. 'Maximum image width: 100px'. |

## Future features
Just some ideas in the making...

 - Drag & Drop, this currently doens't work - you have to use the button currently.
 - Support multiple image variations. e.g. Responsive images.
 -  Ability to multi select, or create a repeatable field for multiple images.

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