Rehype plugin to set the size of img elements.
For remote images, a small amount of data is downloaded internally to get the size.
## remote image
![](https://cdn.example.com/sample.png)
## local image
![](/sample.png)
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);
probe-image-size get image size without full download.
No need to download the entire image to get the dimensions.