From d79613f3def409cdd22bc444f9b733de2dc3fc77 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Tue, 19 Jun 2018 10:19:00 +0800 Subject: [PATCH] feat: support image resizing, resolve #508 --- docs/helpers.md | 34 ++++++++++++++++++++++------------ src/core/render/compiler.js | 10 ++++++++++ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/docs/helpers.md b/docs/helpers.md index 59a299cf7..764b88a86 100644 --- a/docs/helpers.md +++ b/docs/helpers.md @@ -66,17 +66,27 @@ You will get `link`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') diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 82544ce92..49242084b 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -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) }