unified

Project:remarkjs/remark-embed-images

Package:remark-embed-images@2.0.0

  1. Dependencies:2·Dependents:0
  2. remark plugin to embed images with data URIs, inlining base64-encoded sources
  1. remark 181
  2. unified 135
  3. plugin 123
  4. markdown 102
  5. mdast 69
  6. remark-plugin 65
  7. image 12
  8. embed 3
  9. inline 3

remark-embed-images

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to embed local images as data URIs, inlining files as base64-encoded values.

Install

npm:

npm install remark-embed-images

Use

Say we have an image, foo.png, and next to it the following file, example.md:

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

And our script, example.js, looks as follows:

var vfile = require('to-vfile')
var remark = require('remark')
var embed = require('remark-embed-images')

remark()
  .use(embed)
  .process(vfile.readSync('example.md'), function(err, file) {
    if (err) throw err
    console.log(String(file))
  })

Now, running node example yields:

![A PNG file](data:image/png;base64,iVBORw0…)

API

remark().use(embedImages)

Embed local images as data URIs, inlining files as base64-encoded values.

Security

Although this plugin should be safe to use, always be careful with user input. For example, it’s possible to hide JavaScript inside images (such as GIFs, WebPs, and SVGs). User provided images open you up to a cross-site scripting (XSS) attack.

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © David Herges