New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

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

Related posts