/remark-embed-images

Embed images with data: URIs, inlining base64-encoded sources

Primary LanguageHTMLMIT LicenseMIT

remark-embed-images

Embed local images with data: URIs, inlining base64-encoded sources

Note, only local images are processed. No HTTP calls are made with this plugin.

Usage

This is a plugin for the remark markdown processor.

Input:

![A PNG](./foo.png)

Process:

const embedImage = require('remark-embed-images');
const vfile = require('to-vfile')
const MARKDOWN = vfile.readSync('myfile.md');

remark()
  .use(embedImages)
  .process(MARKDOWN, function (err, file) {
    vfile.writeSync({path: 'myfile_inlined.md', contents: String(file)});
  });

Output:

![A PNG](data:image/png;base64,0000...)