Hide Base64 Image
unlistedby Custom
永久隐藏Base64图片编码,任何操作都不展开,只显示![名称]
Base64 Image Hider for Obsidian
When you use plugins like Image Inline to embed images as data:image/png;base64,... data URIs, each image injects a massive block of text into your Markdown file:

Problem: These multi-kilobyte data URIs cause the CodeMirror editor to lag during scrolling, typing, and file switching. Clicking on them expands the cursor into the base64 blob, making editing painful. The horizontal scrollbar stretches to accommodate the single long line.
Solution: This plugin uses a CodeMirror 6 ViewPlugin with Decoration.replace to permanently fold every base64 data URI into a compact … widget. The widget is deliberately locked — it consumes all mouse and keyboard events, so you can never accidentally expand into the base64 content.
How It Works
Before: 
After: …
- Matches
from Image Inline and any baredata:...;base64,...URIs - Replaces the entire match with a
WidgetTypethat renders… - Blocks all events on the widget (
ignoreEventreturnstrue), making expansion impossible - Scroll-safe: CSS constraints prevent the hidden text from stretching the editor horizontally
- Keyboard navigable: arrow keys still pass through normally; you can select and delete around the widget
- Settings panel: toggle the plugin on/off (requires restart)
- Startup-friendly: CM6 extension registered after
onLayoutReady, avoiding contribution to Obsidian's startup timer
Installation
From Obsidian Community Plugins (pending review)
Not yet listed. Use manual installation below.
Manual Installation
cd /path/to/your/vault/.obsidian/plugins
git clone https://github.com/Air-0000/obsidian-base64-hider.git
Then enable "Base64 Image Hider" in Settings → Community Plugins.
BRAT (Beta Reviewers Auto-update Tester)
Add Air-0000/obsidian-base64-hider as a beta plugin in BRAT.
Compatibility
| Plugin | Status |
|---|---|
| Image Inline | Fully compatible |
| Excalidraw | Does not interfere with .excalidraw.md files |
Any plugin inserting data:...;base64,... | Covered by bare-URI regex |
Requires Obsidian >= 1.4.0 (CodeMirror 6 editor).
Why Not Use Obsidian's Built-in Folding?
Obsidian's native fold API (applyFoldInfo) requires heading-based fold ranges (# Section → content). Inline base64 data URIs have no heading wrapper, so the fold API cannot hide them.
Technical Details
The plugin uses three CodeMirror 6 primitives:
Decoration.replace— substitutes the base64 range with a compact widget, removing the text from layout calculationsWidgetTypesubclass — implementstoDOM,eq,compare,destroy,updateDOM,coordsAt,estimatedHeight, and criticallyignoreEvent(returnstrue)ViewPlugin.fromClass— re-scans the document on every change or viewport shift to keep all base64 ranges folded
Two regex patterns are applied in descending-from order (to prevent position drift):
| Pattern | Matches |
|---|---|
!\[(.*?)\]\((data:image\/[^;]+;base64,[A-Za-z0-9+/=]+)\) | Image Inline syntax |
data:[^;]+;base64,[A-Za-z0-9+/=]{40,} | Any bare data URI (≥40 chars) |
How to Temporarily View the Base64
If you need to edit the base64 content (e.g., to change the image source), disable the plugin in Settings → Community Plugins, edit the file, then re-enable.
License
MIT
中文说明 {#chinese}
问题
当你使用 Image Inline 等插件将图片以 base64 形式嵌入 Markdown 时,每张图片会插入巨量的 data:image/png;base64,... 文本:

这会导致编辑器滚动卡顿、输入延迟、文件切换变慢。点击展开后的水平滚动条会拉得很远,编辑体验极差。
解决方案
这个插件通过 CodeMirror 6 的 Decoration.replace 机制,将所有 base64 数据 URI 永久替换为 … 小组件。该组件拦截所有点击和键盘事件,无论如何操作都不会展开 base64 内容。
效果
替换前: 
替换后: …
- 自动匹配
和裸data:...;base64,...两种格式 - 完整的 WidgetType 实现,含
eq、compare、destroy、updateDOM、coordsAt、estimatedHeight ignoreEvent返回true,彻底阻止展开- CSS 兜底防止水平滚动条被撑开
- 与 Excalidraw 插件互不干扰
安装
cd /你的仓库/.obsidian/plugins
git clone https://github.com/Air-0000/obsidian-base64-hider.git
然后在设置 → 第三方插件中启用即可。
原理
Obsidian 内置的折叠 API(applyFoldInfo)依赖标题层级(# Section → content),无法处理行内的 base64。本插件直接使用 CodeMirror 6 的 ViewPlugin + Decoration.replace,在编辑器渲染层做替换,不修改原文内容。
如何临时查看原文
禁用此插件 → 编辑文件 → 重新启用。
许可证
MIT
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.