Image
Improve image syntax in Markdown to support color scheme and size.
Settings
import { hopeTheme } from "vuepress-theme-hope";
export default hopeTheme({
markdown: {
// Enable figure
figure: true,
// Enable image lazyload
imgLazyload: true,
// Enable image mark
imgMark: true,
// Enable image size
imgSize: true,
},
});
Image Lazyload
This feature enables lazyload with native HTML5, so your browser must support loading=lazy attribute.
Image Mark
This feature allows you to mark images with #light
and #dark
suffix to display them in a specific color scheme.


Advanced
You can pass an object to markdown.imgMark
to config ID marks:
import { hopeTheme } from "vuepress-theme-hope";
export default hopeTheme({
markdown: {
imgMark: {
/** light mode only IDs */
light: ["light"],
/** dark mode only IDs */
dark: ["dark"],
},
},
});
Image Size
You can append =widthxheight
to image alt text with spaces as separator.
Both width
and height
should be numbers as pixels and are optional.



Renders as ↓
<img src="/example.png" alt="Alt" width="200" height="300" />
<img src="/example.jpg" alt="Alt" title="Title" width="200" />
<img src="/example.bmp" alt="Alt" height="300" />
Obsidian Syntax
When you set markdown.obsidianImgSize: true
in theme options, you can append widthxheight
after image alt text and use |
to separate.
Both width
and height
should be numbers as pixels and are required. Setting one of them with 0
to scale by ratio with the other.



Renders as ↓
<img src="/example.png" alt="Alt" width="200" height="300" />
<img src="/example.jpg" alt="Alt" width="200" />
<img src="/example.bmp" alt="Alt" height="300" />
Legacy Syntax (Deprecated)
This may cause rendering issues on platforms like GitHub.
When you set markdown.legacyImgSize: true
in theme options, you can append =widthxheight
at the end of image link section with spaces as separator.
Both width
and height
should be numbers as pixels and are optional.



Renders as ↓
<img src="/example.png" width="200" height="300" />
<img src="/example.jpg" title="TTitle" width="200" />
<img src="/example.bmp" height="300" />
Choosing between 3 Grammars
- The legacy grammar breaks image rendering in environments that don't support it (e.g.: GitHub)
- Both the new grammar and the Obsidian grammar are compatible with the Markdown standard, but new grammar is more natural.
Figure
Sometimes, you may want to add a description with image and place it between contents, in this case you should use this feature to convert images to <figure>
.
If the image is standalone in a line, wrapped or not wrapped by link, it will be displayed as <figure>
and title (or alt) will be displayed as <figcaption>
.


[](https://theme-hope.vuejs.press/)

[](https://theme-hope.vuejs.press/)

Changelog
1e9f5
-ond8e7e
-ona1439
-on06ef8
-on55e92
-onb1230
-on22787
-on6ad69
-onb41c0
-on54c46
-on55ea3
-on757fd
-on83bff
-on16eb1
-on3a6d6
-on2a306
-onb7879
-on8174c
-onc8d60
-on6e91a
-on79ac6
-onb4289
-on2243a
-on19d23
-on23f74
-on2c32c
-on3dac6
-on2fa50
-on3c8d6
-ond48cc
-on