Skip to content

Commit 3a7ad62

Browse files
authored
feat: support image resizing, resolve #508 (#545)
* feat: support image resizing, resolve #508 * add docs
1 parent feea7f9 commit 3a7ad62

File tree

4 files changed

+76
-36
lines changed

4 files changed

+76
-36
lines changed

Diff for: docs/de-de/helpers.md

+22-12
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,27 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
6060
## Github Task Lists
6161

6262
```md
63-
* [ ] foo
64-
* bar
65-
* [x] baz
66-
* [] bam <~ not working
67-
* [ ] bim
68-
* [ ] lim
63+
- [ ] foo
64+
- bar
65+
- [x] baz
66+
- [] bam <~ not working
67+
- [ ] bim
68+
- [ ] lim
6969
```
7070

71-
* [ ] foo
72-
* bar
73-
* [x] baz
74-
* [] bam <~ not working
75-
* [ ] bim
76-
* [ ] lim
71+
- [ ] foo
72+
- bar
73+
- [x] baz
74+
- [] bam <~ not working
75+
- [ ] bim
76+
- [ ] lim
77+
78+
## Image resizing
79+
80+
```md
81+
![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
82+
![logo](https://docsify.js.org/_media/icon.svg ':size=100')
83+
```
84+
85+
![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
86+
![logo](https://docsify.js.org/_media/icon.svg ':size=100')

Diff for: docs/helpers.md

+22-12
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,27 @@ You will get `<a href="/demo/">link</a>`html. Do not worry, you can still set ti
6666
## Github Task Lists
6767

6868
```md
69-
* [ ] foo
70-
* bar
71-
* [x] baz
72-
* [] bam <~ not working
73-
* [ ] bim
74-
* [ ] lim
69+
- [ ] foo
70+
- bar
71+
- [x] baz
72+
- [] bam <~ not working
73+
- [ ] bim
74+
- [ ] lim
7575
```
7676

77-
* [ ] foo
78-
* bar
79-
* [x] baz
80-
* [] bam <~ not working
81-
* [ ] bim
82-
* [ ] lim
77+
- [ ] foo
78+
- bar
79+
- [x] baz
80+
- [] bam <~ not working
81+
- [ ] bim
82+
- [ ] lim
83+
84+
## Image resizing
85+
86+
```md
87+
![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
88+
![logo](https://docsify.js.org/_media/icon.svg ':size=100')
89+
```
90+
91+
![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
92+
![logo](https://docsify.js.org/_media/icon.svg ':size=100')

Diff for: docs/zh-cn/helpers.md

+22-12
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,27 @@ docsify 扩展了一些 Markdown 语法,可以让文档更易读。
5656
## Github 任务列表
5757

5858
```md
59-
* [ ] foo
60-
* bar
61-
* [x] baz
62-
* [] bam <~ not working
63-
* [ ] bim
64-
* [ ] lim
59+
- [ ] foo
60+
- bar
61+
- [x] baz
62+
- [] bam <~ not working
63+
- [ ] bim
64+
- [ ] lim
6565
```
6666

67-
* [ ] foo
68-
* bar
69-
* [x] baz
70-
* [] bam <~ not working
71-
* [ ] bim
72-
* [ ] lim
67+
- [ ] foo
68+
- bar
69+
- [x] baz
70+
- [] bam <~ not working
71+
- [ ] bim
72+
- [ ] lim
73+
74+
## Image resizing
75+
76+
```md
77+
![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
78+
![logo](https://docsify.js.org/_media/icon.svg ':size=100')
79+
```
80+
81+
![logo](https://docsify.js.org/_media/icon.svg ':size=50x100')
82+
![logo](https://docsify.js.org/_media/icon.svg ':size=100')

Diff for: src/core/render/compiler.js

+10
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,16 @@ export class Compiler {
257257
attrs += ` title="${title}"`
258258
}
259259

260+
const size = config.size
261+
if (size) {
262+
const sizes = size.split('x')
263+
if (sizes[1]) {
264+
attrs += 'width=' + sizes[0] + ' height=' + sizes[1]
265+
} else {
266+
attrs += 'width=' + sizes[0]
267+
}
268+
}
269+
260270
if (!isAbsolutePath(href)) {
261271
url = getPath(contentBase, getParentPath(router.getCurrentPath()), href)
262272
}

0 commit comments

Comments
 (0)