I am pulling in data from airtable that uses an external URL inside of its quite long markdown, something like this:
...
testing
<img src="https://via.placeholder.com/150" width="300px" />
...
However, when this is built and rendered, the image is still pointed to the external link and is not downloaded locally. Is there a way to transform incoming MDX images, download them, and then change the respective source to behave much like Gatsby's image would? It'd be nice for them to also get the progressive loading enhancements etc. That Gatsby offers.
The solutions offered here Gatsby Static Image(gatsby-plugin-image) inside MDX are not suitable, and the last answer in that post does not seem to work but maybe hints at a possible solution.
I also tried to use MDX provider and renderer to bake own my custom MDX renderer. It works fine if I want users to use some special react components, but obviously, it fails when I try to use it to intercept an img
tag and replace it with Gatsby's StaticImage
. This is because the external URL comes in as a prop, and is disallowed by gatsby static analyzer.