Skip to content

Commit

Permalink
feat: support image resizing, resolve #508 (#545)
Browse files Browse the repository at this point in the history
* feat: support image resizing, resolve #508

* add docs
  • Loading branch information
QingWei-Li authored Jun 29, 2018
1 parent feea7f9 commit 3a7ad62
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 36 deletions.
34 changes: 22 additions & 12 deletions docs/de-de/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,27 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
## Github Task Lists

```md
* [ ] foo
* bar
* [x] baz
* [] bam <~ not working
* [ ] bim
* [ ] lim
- [ ] foo
- bar
- [x] baz
- [] bam <~ not working
- [ ] bim
- [ ] lim
```

* [ ] foo
* bar
* [x] baz
* [] bam <~ not working
* [ ] bim
* [ ] lim
- [ ] foo
- bar
- [x] baz
- [] bam <~ not working
- [ ] bim
- [ ] lim

## Image resizing

```md
![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
![logo](https://docsify.js.org/_media/icon.svg ':size=100')
```

![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
![logo](https://docsify.js.org/_media/icon.svg ':size=100')
34 changes: 22 additions & 12 deletions docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,27 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
## Github Task Lists

```md
* [ ] foo
* bar
* [x] baz
* [] bam <~ not working
* [ ] bim
* [ ] lim
- [ ] foo
- bar
- [x] baz
- [] bam <~ not working
- [ ] bim
- [ ] lim
```

* [ ] foo
* bar
* [x] baz
* [] bam <~ not working
* [ ] bim
* [ ] lim
- [ ] foo
- bar
- [x] baz
- [] bam <~ not working
- [ ] bim
- [ ] lim

## Image resizing

```md
![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
![logo](https://docsify.js.org/_media/icon.svg ':size=100')
```

![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
![logo](https://docsify.js.org/_media/icon.svg ':size=100')
34 changes: 22 additions & 12 deletions docs/zh-cn/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,27 @@ docsify 扩展了一些 Markdown 语法,可以让文档更易读。
## Github 任务列表

```md
* [ ] foo
* bar
* [x] baz
* [] bam <~ not working
* [ ] bim
* [ ] lim
- [ ] foo
- bar
- [x] baz
- [] bam <~ not working
- [ ] bim
- [ ] lim
```

* [ ] foo
* bar
* [x] baz
* [] bam <~ not working
* [ ] bim
* [ ] lim
- [ ] foo
- bar
- [x] baz
- [] bam <~ not working
- [ ] bim
- [ ] lim

## Image resizing

```md
![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
![logo](https://docsify.js.org/_media/icon.svg ':size=100')
```

![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
![logo](https://docsify.js.org/_media/icon.svg ':size=100')
10 changes: 10 additions & 0 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ export class Compiler {
attrs += ` title="${title}"`
}

const size = config.size
if (size) {
const sizes = size.split('x')
if (sizes[1]) {
attrs += 'width=' + sizes[0] + ' height=' + sizes[1]
} else {
attrs += 'width=' + sizes[0]
}
}

if (!isAbsolutePath(href)) {
url = getPath(contentBase, getParentPath(router.getCurrentPath()), href)
}
Expand Down

0 comments on commit 3a7ad62

Please sign in to comment.