🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

oss-webp

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oss-webp

Detect browser compatibility with webp, add suffix when webp is available

latest
Source
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

oss-webp

检测浏览器与webp的兼容性,在webp可用时添加后缀

安装

npm i oss-webp -S

使用

import ossWebp from "oss-webp";
ossWebp('yourOssImage.jpg',customSuffix).then(r=>{
	console.log(r);
})

完整示例

####原生Js

ossWebp('https://image1.aliyuncs.jpg','/resize,l_100').then(r=>{
	console.log(r); 
	//output: https://image1.aliyuncs.jpg?x-oss-process=image/resize,l_100/format,webp
})

####Angular pipe

import { Pipe, PipeTransform } from "@angular/core";
import ossWebp from "oss-webp";
import {Observable} from "rxjs";

@Pipe({
  name: "webp"
})
export class WebpPipe implements PipeTransform {
  transform(value: any, args?: any): any {
      return new Observable(observer=>{
          ossWebp(value,args?args:'').then(r => {
              observer.next(r)
          });
      })
  }
}

Keywords

oss

FAQs

Package last updated on 16 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts