npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-oss-image

v1.2.1

Published

![NPM Version](https://img.shields.io/npm/v/vue-oss-image) ![Support Vue3](https://img.shields.io/badge/vue-3.x-42b883) ![GitHub License](https://img.shields.io/github/license/banrikun/vue-oss-image)

Downloads

10

Readme

Vue OSS Image

NPM Version Support Vue3 GitHub License

A custom directive designed for Vue 3 to generate Alibaba Cloud OSS image URLs.

Quick Start

npm install vue-oss-image --save
import { createApp } from 'vue'
import VueOssImage from 'vue-oss-image'
import App from './App.vue'

const app = createApp(App)
app.use(VueOssImage, {
  // global options
  host: 'https://test.com',
  resizeMode: 'fill'
})
app.mount('#app')
<img v-img="'example.jpg'">
<!-- => src="https://test.com/example.jpg" -->

<img v-img="{ host: 'https://demo.com', path: '/example.jpg', width: 100, height: 50, ratio: 2 }">
<!-- => src="https://demo.com/example.jpg?x-oss-process=image/resize,m_fill,w_200,h_100" -->

<div v-img="{ path: 'example.jpg' }"></div>
<!-- => style.backgroundImage = 'url(https://test.com/example.jpg)' -->

Options

| Name | Global | Directive | .compose | Description | |-|:-:|:-:|:-:|-| | quality | ✅ | ✅ | ✅ | [Number] Quality, supports integers from 1 to 100 | | format | ✅ | ✅ | ✅ | [String] Format conversion, supports webp jpg png bmp gif tiff | | resizeMode | ✅ | ✅ | ✅ | [String] Resize mode, supports fill lfit mfit pad fixed, default is fill | | ratio | ✅ | ✅ | ✅ | [Number] Resize ratio, default is window.devicePixelRatio | | loading | ✅ | ✅ | 🚫 | [String] Displayed during loading, with other behaviors consistent with path | | error | ✅ | ✅ | 🚫 | [String] Displayed in case of loading error, with other behaviors consistent with path | | attr | ✅ | ✅ | 🚫 | [String] Specify the attribute for replacing the image URL, default is determined based on the element's tagName | | host | ✅ | ✅ | ✅ | [String] The prefix for the image URL | | path | 🚫 | ✅ | ✅ | [String] If it starts with http(s)://, host will be ignored. If it's a base64 image, it will be returned as a complete URL | | width | 🚫 | ✅ | ✅ | [Number] Cannot be used with long or short | | height | 🚫 | ✅ | ✅ | [Number] Cannot be used with long or short | | long | 🚫 | ✅ | ✅ | [Number] Cannot be used with width or height | | short | 🚫 | ✅ | ✅ | [Number] Cannot be used with width or height |

See more

Advanced Usage

Custom Properties and Methods

const myOssImage = VueOssImage.create({
  // global options
})
myOssImage.prototype.$compose = () => {}
// Using myOssImage instead of the global options object
app.use(VueOssImage, myOssImage)

Custom Directive Name

const myOssImage = VueOssImage.create({
  // global options
})
// In this case, there's no need to use `app.use`
app.directive('my-directive', VueOssImage.createHooks(myOssImage))

Using with the VueLazyload Library

// <script setup>
const loadingUrl = VueOssImage.compose({
  host: 'https://test.com',
  path: 'loading.png'
})
const errorUrl = VueOssImage.compose({
  host: 'https://test.com',
  path: 'error.png'
})
<div v-lazy-container="{ selector: 'img', loading: loadingUrl, error: errorUrl }">
  <img v-img="{ path: 'example.jpg', attr: 'data-src' }">
</div>

See more

License

MIT