1.0.0 • Published 3 years ago

rehype-probe-image-size v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

main

rehype-probe-image-size

Rehype plugin to set the size of img elements.

For remote images, a small amount of data is downloaded internally to get the size.

Syntax

## remote image
![](https://cdn.example.com/sample.png)

## local image
![](/sample.png)

Example

import unified from "unified";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";
import rehypeProbeImageSize from "rehype-probe-image-size";

unified()
  .use(remarkParse)
  .use(remarkRehype)
  .use(rehypeProbeImageSize, { staticDir: "public" })
  .use(rehypeStringify)
  .process(markdown);

Dependencies

probe-image-size

probe-image-size get image size without full download.

No need to download the entire image to get the dimensions.