0x1da9430847 downloadsPaste images as HTML format instead of wikilink or markdown format.
A plugin for Obsidian that converts pasted images to HTML format instead of Obsidian's wikilink or Markdown format.
./assets)HTML image tags offer better compatibility across different platforms compared to Markdown or Obsidian's wikilink format. This is particularly useful for users who need to share their notes across different platforms and Markdown editors.
<img src="https://raw.githubusercontent.com/0x1da9430/img2html/HEAD/image_name.jpg" width="auto">You can enable the "Use Custom Image Path" option in settings and set a custom save path for your images:
./assets or ../images): Images will be saved in the specified directory relative to the current fileassets or images): Images will be saved in the specified directory under your vault rootWhen custom path is enabled, the src attribute in HTML tags will be updated accordingly, for example:
<img src="https://raw.githubusercontent.com/0x1da9430/img2html/HEAD/assets/image_1234567890.jpg" width="auto">
If custom path is disabled, images will be saved in the same directory as the current file, and the HTML tag will only use the filename:
<img src="https://raw.githubusercontent.com/0x1da9430/img2html/HEAD/image_1234567890.jpg" width="auto">
By default, the plugin generates HTML tags without the alt attribute to keep the code concise. If you need better accessibility or SEO optimization, you can enable the "Include Alt Attribute" option in settings, which will generate tags like:
<img src="https://raw.githubusercontent.com/0x1da9430/img2html/HEAD/image_1234567890.jpg" width="auto" alt="image_1234567890.jpg">
You can enable "Use custom attributes" to disable both the image width and alt tag setting in favor of a fully custom list of attributes, such as a custom CSS class or variables therein. Using this function, you can generate tags like:
<img src="https://raw.githubusercontent.com/0x1da9430/img2html/HEAD/assets/image_1778330017341.png" class="image-class" style="--img-width: 40vw;">
main.js, manifest.json, and styles.css.obsidian/plugins/img2html/ directorynpm install to install dependenciesnpm run dev to start compilation in watch modemain.js and manifest.json to your vault's .obsidian/plugins/img2html/ directory for testingMIT