Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Dec 17, 2019
2 parents 65ec208 + 166d27a commit 8813863
Show file tree
Hide file tree
Showing 5 changed files with 565 additions and 478 deletions.
32 changes: 0 additions & 32 deletions .grenrc.js

This file was deleted.

19 changes: 11 additions & 8 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

- 输入 jpg/png,输出 webp(svg/gif 原样返回,不做转换处理)
- 根据浏览器环境自动选择是否使用 webp
- 支持多提供商参数配置
- 支持云服务
- [x] 阿里云
- [x] 七牛

Expand All @@ -50,9 +50,11 @@ yarn add @femessage/v-img
- self
- none

默认值为 alibaba, 如果项目中使用阿里云 OSS 进行图片存储,则可省略设置`provider`
---

`provider=self` 时,也即图片放到自有主机,一般出现在项目私有化部署的情况,此时需为每一份图片自行准备相应的 webp 文件。 例如:
- 默认值为 alibaba。这意味着,只需要上传 jpg/png 到阿里云 OSS,使用 v-img 来显示图片,则会使用阿里云的图片处理服务,根据情况自动返回 webp。如果项目中已使用阿里云 OSS 进行图片存储,则可省略设置`provider`

-`provider=self` 时,也即图片放到自有主机,一般出现在项目私有化部署的情况,此时需为每一份图片自行准备相应的 webp 文件。 例如:

```sh
images/
Expand All @@ -62,12 +64,12 @@ images/

生成 webp 副本的方法可查看[此文](https://www.yuque.com/docs/share/3eaa556c-0780-4018-8ac1-4e217fb0efdb)

`provider=none` 时,仅启用图片懒加载功能
- `provider=none` 时,仅启用图片懒加载功能

总结一下就是:
1.`provider=alibaba或qiniu` 时,酌情转webp,默认对图片瘦身
2.`provider=self` 时,酌情转webp,方式是按规则拼接src,期望用户准备好webp文件
3.`provider=none` 时,不对src做处理
1.`provider=alibaba或qiniu` 时,使用云服务商图片处理功能,自动转 webp,默认对图片瘦身
2.`provider=self` 时,期望用户准备好 webp 文件,判断浏览器环境支持 webp 时,请求 webp 图片
3.`provider=none` 时,不对 src 做处理

### width/height

Expand All @@ -81,7 +83,8 @@ images/

## Links

- [docs](https://FEMessage.github.io/v-img/)
- [api](https://FEMessage.github.io/v-img/)
- [设计文档](https://www.yuque.com/docs/share/6edaadbb-9260-4b49-90d7-0a8d8d03b1de)
- [webp](https://developers.google.com/speed/webp)
- [alibaba oss guide](https://www.alibabacloud.com/help/doc-detail/47505.html?spm=a2c5t.11065259.1996646101.searchclickresult.2c802d29Uot0hD)
- [qiniu images processing doc](https://developer.qiniu.com/dora/api/1270/the-advanced-treatment-of-images-imagemogr2)
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This component aims to replace native img element and use webp!

- Input jpg/png, output webp(svg/gif not be processed)
- Automatically check whether your browser support webp and use it
- Support multi-provider image service
- Support cloud image service
- [x] Alibaba
- [x] Qiniu

Expand Down Expand Up @@ -54,9 +54,11 @@ The component use `provider` to choose image processing strategy, here are avail
- self
- none

Alibaba OSS services are used by default, so if you host images on Alibaba OSS, `provider` can be omitted
---

When `provider=self`, means you host images on your server(like Nginx), this needs you need to prepare a webp file for each image, for example:
- Alibaba OSS services are used by default, so if you host images on Alibaba OSS, `provider` can be omitted, this means jpg/png on Alibaba OSS, you can get webp when using v-img

- When `provider=self`, means you host images on your server(like Nginx), this needs you need to prepare a webp file for each image, for example:

```sh
images/
Expand All @@ -66,7 +68,7 @@ images/

look at this [article](https://www.yuque.com/docs/share/3eaa556c-0780-4018-8ac1-4e217fb0efdb?translate=en) to see how to use node.js to generate webp from jpg/png

When `provider=none`, it only enable lazyload images function
- When `provider=none`, it only enable lazyload images function

### width/height

Expand All @@ -80,7 +82,8 @@ The `lazyload` function is supported by [lazysizes](https://github.com/aFarkas/l

## Links

- [docs](https://FEMessage.github.io/v-img/)
- [api](https://FEMessage.github.io/v-img/)
- [design doc](https://www.yuque.com/docs/share/6edaadbb-9260-4b49-90d7-0a8d8d03b1de?translate=en)
- [webp](https://developers.google.com/speed/webp)
- [alibaba oss guide](https://www.alibabacloud.com/help/doc-detail/47505.html?spm=a2c5t.11065259.1996646101.searchclickresult.2c802d29Uot0hD)
- [qiniu images processing doc](https://developer.qiniu.com/dora/api/1270/the-advanced-treatment-of-images-imagemogr2)
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"@babel/core": "^7.4.3",
"@babel/plugin-transform-runtime": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@femessage/github-release-notes": "^0.19.0",
"babel-loader": "^8.0.5",
"file-loader": "^3.0.1",
"github-release-notes": "^0.17.0",
"glob": "^7.1.3",
"husky": "1.3.1",
"jest": "^24.8.0",
Expand Down Expand Up @@ -92,5 +92,6 @@
"stylelint --fix",
"git add"
]
}
},
"gren": "@femessage/grenrc"
}
Loading

0 comments on commit 8813863

Please sign in to comment.